Last active
April 30, 2021 11:43
-
-
Save syedjafer/7a4b2d0405bbbe6367494a382edc8f80 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 partition(array, start, end): | |
| pivot = array[end] | |
| partition_index = start | |
| print(pivot, partition_index) | |
| for itr in range(start, end): | |
| if array[itr] < pivot: | |
| array[partition_index], array[itr] = array[itr], array[partition_index] | |
| partition_index += 1 | |
| print(array) | |
| array[partition_index], array[end] = array[end], array[partition_index] | |
| print(array) | |
| array = [3, 8, 6, 2, 4, 7, 8, 5] | |
| start = 0 | |
| end = len(array)-1 | |
| partition(array, start, end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment