I'm trying to run merge sort using python and recursion it is working fine for some cases not not working fine for most of the cases please correct me I tried and unable to find error in code.
def merge_sort(a,min,max):
if max-min<2:
return a[min:max]
mid=(min+max)//2
L=merge_sort(a,min,mid)
R=merge_sort(a,mid,max)
return(sort(L,R))
def sort(L,R):
(c,m,n)=([],len(L),len(R))
(i,j)=(0,0)
while(i+jif i==m :
c.append(R[j])
j+=1
elif j==m :
c.append(L[i])
i+=1
elif R[j]<=L[i]:
c.append(R[j])
j+=1
elif L[i]1
return c