Moved quick sort algorithm from main branch to testing branch

This commit is contained in:
K 2023-09-29 15:56:35 +05:30
parent 1e357e52bd
commit 65d3159478
Signed by: notkshitij
GPG Key ID: C5B8BC7530F8F43F

38
quicksortEarlyAccess.py Normal file
View File

@ -0,0 +1,38 @@
no = int(input("Enter number of students: "))
list2 = []
#list1 = []
for i in range(0,no):
n = float(input("Enter % of student: "))
list2.append(n)
print(list2)
d = len(list2)
def partition(list3,a,b):
v = list3[a]
i = a
j = b-1
temp = 0
while(i<j):
while(list3[i]<=v and i<=j):
i = i + 1
while(list3[j] > v):
j = j - 1
if(i<j):
temp = list3[i]
list3[i] = list3[j]
list3[j] = temp
list3[a] = list3[j]
list3[j] = v
return j
def quicksort(list1, l, u):
j = 0
if(l<u):
j = partition(list1,l,u)
quicksort(list1,l,j - 1)
quicksort(list1,j+1,u)
list2 = list1
return list2
o = quicksort(list2,0,d)
print("Sorted list is: ",o)