Skip to content

Instantly share code, notes, and snippets.

@umangshrestha
Created June 18, 2020 04:48
Show Gist options
  • Save umangshrestha/51f8340d4a8298a0f851c147c19b6ebe to your computer and use it in GitHub Desktop.
Save umangshrestha/51f8340d4a8298a0f851c147c19b6ebe to your computer and use it in GitHub Desktop.
def partition(array, low, high):
pivot = array[high]
i = low - 1
for j in range(low , high):
if array[j] < pivot:
print(array)
i = i + 1
array[i], array[j] = array[j], array[i]
array[high], array[i + 1] = array[i + 1], array[high]
return i + 1
def quickSort(array, low, high):
if low < high:
pi = partition(array, low, high)
quickSort(array, pi+1, high)
quickSort(array, low, pi-1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment