A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/d5/df4/merge__sort_8cpp_source.html below:

TheAlgorithms/C++: sorting/merge_sort.cpp Source File

Go to the documentation of this file. 37void merge

(

int

*arr,

int

l,

int

m,

int

r) {

41

std::vector<int> L(n1), R(n2);

43 for

(

int

i = 0; i < n1; i++) L[i] = arr[l + i];

44 for

(

int

j = 0; j < n2; j++) R[j] = arr[m + 1 + j];

46 int

i = 0, j = 0, k = l;

48 while

(i < n1 && j < n2) {

84 int

m = l + (r - l) / 2;

95void show

(

int

*arr,

int

size) {

96 for

(

int

i = 0; i < size; i++) std::cout << arr[i] <<

" "

;

103

std::cout <<

"Enter the number of elements: "

;

107

std::cout <<

"Invalid size.\n"

;

111 int

*arr =

new int

[size];

112

std::cout <<

"Enter the unsorted elements: "

;

113 for

(

int

i = 0; i < size; ++i) {

118

std::cout <<

"Sorted array: "

;

void show(int *arr, int size)

void merge(int *arr, int l, int m, int r)

void mergeSort(int *arr, int l, int r)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4