i couldn’t understand how did the divided parts get sorted
Problem with understanding
have you watch this video??
yes, i get the that the merge function is the one sorting but the merge function is called from starting to end
so what is the problem?
like how that merge function is sorting the divided parts
in merge function first you make two array
now these two arrays are sorted so just use the logic of “Merge two sorted array”
- Create an array arr3[] of size n1 + n2.
- Simultaneously traverse arr1[] and arr2[]
Pick smaller of current elements in arr1[] and arr2[], copy this smaller element to next position in arr3[] and move ahead in arr3[] and the array whose element is picked. - If there are remaining elements in arr1[] or arr2[], copy them also in arr3[].