Skip to content

Instantly share code, notes, and snippets.

@Goodguyr
Created November 12, 2020 14:07
Show Gist options
  • Save Goodguyr/39893a61fca1a338612076bd6e91ee14 to your computer and use it in GitHub Desktop.
Save Goodguyr/39893a61fca1a338612076bd6e91ee14 to your computer and use it in GitHub Desktop.
Incorrect code from the quiz
def quickSort(arr):
l = 0
r = len(arr) - 1
if l < r:
i = l
j = r + 1
v = arr[l]
while i < j:
i += 1
while i < r and arr[i] < v:
i += 1
j -= 1
while j > l and arr[j] > v:
j -= 1
temp = arr[i]
arr[i] = arr[j]
arr[j] = temp
temp = arr[i]
arr[i] = arr[j]
arr[j] = temp
temp = arr[j]
arr[j] = arr[l]
arr[l] = temp
quickSort(arr[l : j])
quickSort(arr[j : r])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment