Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Quick sort
def quickSort(array,low,high): #base condition if(low<high): part = partition(array,low,high) #partition array into halves where lower half has values smaller than pivot and other half greater values than pivot quickSort(array,low,part-1) quickSort(array,part+1,high) def partition(array,low,high): pivot = array[high] x = low-1 y = low while(y<high): if(array[y]<=pivot): #swapping lower value with higher one so lower values accumalate one side and higher other side x+=1 array[x],array[y] = array[y],array[x] y+=1 array[x+1],array[high] = array[high],array[x+1] #return new pivot return x+1 array = [2,1,5,3,6,0,8] low = 0 high = len(array)-1 quickSort(array,low,high) print(array)
run
|
edit
|
history
|
help
0
perform_math.py
shuru12
WORD THING
Prac1_2
mbti
probl2_203700377
Calculate Volume of Sphere
Program of cube
PyAbs
Owl