I am having some trouble with my quicksort. Here is my program:
def main():
Array = [10, 5, 3, 8, 6, 7, 4, 9, 2, 1, 10]
right_index = (len(Array) - 1)
left_index = 0
Quicksort(Array, left_index, right_index)
def Quicksort(Array, left_index, right_index):
if len(Array) == 1:
return Array
pivot_index = Partition(Array, left_index, right_index)
Quicksort(Array, left_index, pivot_index-1)
Quicksort(Array, pivot_index + 1, right_index)
return Array
def Partition(Array, left_index, right_index):
pivot = Array[left_index]
i = left_index + 1
for j in range(left_index + 1, right_index):
if Array[j] <= pivot:
Array[j], Array[i] = Array[i], Array[j]
i += 1
Array[left_index], Array[i - 1] = Array[i - 1], Array[left_index]
return i - 1
main()
Am I doing something wrong? I get the error: for j in range(left_index + 1, right_index):
RecursionError: maximum recursion depth exceeded in comparison".
Thanks for any assistance anyone out there may have.