Question: Debug my Quick Sort Function in Python? Here's what it is suppose to do Sort the list using an initial pivot value that is inputted

Debug my Quick Sort Function in Python?

Here's what it is suppose to do

Sort the list using an initial pivot value that is inputted by the user upon calling the function, and 2 empty lists that will contain the halves. after the first call it will use the halves of the list smaller than and greater than the pivot for recursion, with index 0 as the pivot.

CODE: https://gist.github.com/anonymous/0e800a6cd625afcf3f37b540fb48799e

def my_sort(lst, right, left, pivot):

right = [] left = []

if ((len(lst) - 0) > 0): for i in range(0, len(lst)-1): if lst[i] <= pivot: left.append(lst[i]) if lst[i] > pivot: right.append(lst[i])

my_sort(right, len(right)-1, 0, 0) my_sort(left, len(left)-1, 0,0) return lst

test1=[5,2,20,1,55,34,25] print(test2) right = [] left = []

pivot = int(input("Enter Pivot Value:")) hacer = my_sort(test1,right,left,pivot)

#put in the list, 2 empty lists and a pivot value(index)

def my_sort(lst, right, left, pivot):

right = [] left = []

if ((len(lst) - 0) > 0): for i in range(0, len(lst)-1): if lst[i] <= pivot: left.append(lst[i]) if lst[i] > pivot: right.append(lst[i])

my_sort(right, len(right)-1, 0, 0) my_sort(left, len(left)-1, 0,0) return lst

test1=[5,2,20,1,55,34,25] print(test2) right = [] left = []

pivot = int(input("Enter Pivot Value:")) hacer = my_sort(test1,right,left,pivot)

#put in the list, 2 empty lists and a pivot value(index)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!