Not getting how it working in stack memory

i am not getting how after dividing up to a base case digits are merging for example:
if we have 6 4 1 3 2 in array

so according to algo;
we first divide it into two half ;
6 4 1 and 3 2
again 6 4 1 will be divide in two part and so on ,at the end we’ll get 6,4 and 1 ,
now i am not getting how this half is sorting i mean
how just after mergesort(a,s,mid)

merge(a,s,e) is working we have mergesort(a,mid+1,e) in between

@Himanshu0123 hey himanshu


see this image or I will suggest you go to online gdb compiler in which you can see how call stack is working.

in step 6 how 38 and 27 is sorting

@Himanshu0123 simple 27 is compare with 38 so 27 is smaller than the 38 then it will comes first.

but how this function caomparing it we didn’t right any command in mergsort function for comparison

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.