How does split sort happen

When we split array in two halves we c
keep on splitting array ointo those halves so how does the two splitted arrays get sorted

@pranjuldwivedi120568
pehle hum mid nikal rahe hai
phir ab hamare paa do array aa gayi,
ek s se mid tak aur dusri mid+1 se e tak.
hum ab mergesort in dono array par call kar rahe hai taaki ye dono array sort ho jaye.
ab iske baad jab dono array sort ho ke aa jayegi tab hum merge function call kareneg jo in dono sorted array ko merge kar dega aur ek final sorted array dega.

bus itna hi hai merge sort.

aur merge algorithm same hai merging of two sorted hai.
to tumhe bhi merging algorithm samajhna hai ,
agar abh bhi samaj nahi aaya to video ek baar phir dekho , sayad samjh aa jaye.

ek baar ye recursion tree dekho sayad samajh aa jaye

hope its clear if yes dont forget to hit like and mark resolved :smiley:

I am asking that in step number 4 and 5 how does compiler get to know to place 27 before 38 cbecause we haven’t told the compiler to do anything like that tht is my only question otherwise i understood what u r saying btw thanks for elaborated diagram

@pranjuldwivedi120568 merge function is doing that part of concatenating 38 and 27
so after merge on these two it will return as 27 38 (sorted)

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.