would anyone know why I am getting the following recursive error on my quicksort? Not sure why I'm getting a "RecursionError: maximum recursion depth exceeded in comparison". I've asked others and they said that my recursion should not be exceeding:
Here is the code:
def merge(array, low, mid, high):
i,j,k = low,mid+1,low
leftarray = array[low:mid+1]
rightarray = array[mid+1:high+1]
temp= [0]*high
while i<=mid and j<=high:
if array[i]<array[j]:
temp[k] = array[i]
i+=1
else:
temp[k] = array[j]
j+=1
k+=1
if i>mid:
temp[k:high+1] = array[j:high+1]
else:
temp[k:high+1] = array[i:mid+1]
array[low:high+1] = temp[low:high+1]
And the error
(base) b98-aruba1-guest-10-110-7-206:desktop ericadamian$ python Quicksort1.py
RecursionError: maximum recursion depth exceeded in comparison
(base) b98-aruba1-guest-10-110-7-206:desktop ericadamian$
Quicksort1(array, index, low, index + 1)This is an infinite recursion. It will call itself with the samelowandindexvalues.-1instead of+1in the first recursive call - yourhighvalue is just getting bigger and bigger each time, so theifstatement will always beTrue