0

Anyone find the error in merge sort algorithm program.syntax error can't assigh to function call line11

def mergesort(list): if lengthlist >1: m=len(list)//2 leftlist=list[:m] rightlist=list[m:] mergesort(leftlist) mergesort(rightlist) i=j=k=0 while i<len(leftlist) and j<len(rightlist) : if leftlist(i) < rightlist(j): list(k)=leftlist(i) i=i+1 k=k+1 else : list(k)=rightlist(j) j=j+1 k=k+1 while i>len(leftlist): list(k)=leftlist(i) i=i+1 k=k+1 while j>len(rightlist): list(k)=rightlist(j) j=j+1 k=k+1 list=[5,4,3,2,1] mergesort(list) print(list)

22nd Mar 2020, 6:02 PM
Ragul P
Ragul P - avatar
1 Odpowiedź
- 1
I'm not sure exactly but do you mean to use list[k] instead of list(k)? If so, there are multiple times that you used the wrong type of bracket.
22nd Mar 2020, 7:09 PM
Russ
Russ - avatar