Challenge: Implement Merge Sort
The mergeSort()
function should recursively sort the subarray mergeSort(array, p, r)
the elements from index p
to index r
of array should be sorted in ascending order.
To remind you of the merge sort algorithm:
If the subarray has size
or , then it's already sorted, and so nothing needs to be done. Otherwise, merge sort uses divide-and-conquer to sort the subarray.
Use merge(array, p, q, r)
to merge sorted sub arrays
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy