i tried many times but i am not able to understa who the function call
meregesort(arr,s,m) and mergesort(a,m+1,e) is retruning a sort array. i have also tried dry run but still it is a doubt hoe it returning a sorts array
How mergresort function is returning an sorted array
hello @Abhishmu5 the recusrion calls which you have mentioned are not returning the merge sort array as sorted but they are just deviding the array into smaller two equal halves until start and end becomes equal.
there should be one more recursion call which will be executed after the start and the end becomes equal and the logoc will be there which will completely sort the array .
if you have any doubt ,you can ask here otherwise please mark this doubt as resolved .
Happy Learning !!
after both recursion call, we have to merge the two array … prateek bhaiya said that , after these two call we will gate 2 sorted array and using two pointer we will merge it. how canwe get two sorted array afater mergesort call
@Abhishmu5 have you understood the recursion properly ?
in the video or tutorial of this there first we have to divide the two array and then we will write function for this in that function we will again merge the arrays in the sorted manner .
the reasin why we are dividing the arrays first is this only that we have to divide the array first and then we have to reunite them in the sorted format .
please see the prattek bhaiyas code after the video explanation .
if you didn’t understand anything please ask here .
Happy Learning !!