Created
July 12, 2020 18:08
-
-
Save chirag-shinde/0a03b2239c47d42627867092c6ca76c0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def quick_sort(arr,start, end): | |
if start < end: | |
pivot = partition(arr, start, end) | |
quick_sort(arr, start, pivot - 1) | |
quick_sort(arr, pivot + 1, end) | |
def partition(arr, start, end): | |
element = arr[start] | |
i = start | |
for j in range(start + 1, end): | |
if arr[j] < element: | |
i += 1 | |
arr[i], arr[j] = arr[j], arr[i] | |
arr[start], arr[i] = arr[i], arr[start] | |
return i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment