I am trying to write an in-place program that would use the quicksort algorithm to sort a list. But it keeps giving an error:
maximum recursion depth exceeded while calling python object.
Although I tried setting recursion limit.
def partition(L,low,high,comparison):
i=low-1
pivot=random_pivot(L)
for j in range(low,high):
if comparison(L[j],pivot):
i+=1
L[i],L[j]=L[j],L[i]
L[i+1],L[high]=L[high],L[i+1]
return i+1
def inplace_Quicksort(L,low,high,comparison):
low=0
high=len(L)-1
if comparison(low,high):
pivot_index=partition(L,low,high,comparison)
inplace_Quicksort(L,low,pivot_index-1,comparison)
inplace_Quicksort(L,pivot_index+1,high,comparison)
print(L)
Can you please have a look at it and explain to me what is wrong? Thank you so much.