Merge Sort Algorithm, in another efficient sorting algorithm that divides the input array into two parts and it calls itself recursively for the two parts. Then merges these two sorted parts. It is a Divide and Conquer algorithm. Merge function used to merge two parts of array. The merge(arr, l, m, r) is a key process that assumes that arr[l..m] and arr[m+1..r] are sorted and merges the two sorted sub-arrays into one.
Merging algorithm function runs by array with left, mid and right indexes, it should be be as given below;
and my_mergesort() functions runs by array, start and end indexes as below;
Full code of Merge Sort Algorithm will be as below in C++ Builder Console VCL application.
Head over and find out more about building Windows apps with modern C++.