Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def quicksort(list, left, right):
- if left == right - 1:
- return
- pivot = list[randint(left, right)]
- lesser = []
- greater = []
- for i in range(left, right):
- if list[i] < pivot:
- lesser.append(list[i])
- else:
- greater.append(list[i])
- for i in range(len(lesser)):
- list[left + i] = lesser[i]
- for i in range(len(greator)):
- list[left + len(lesser) + i] = greater[i]
- # тут освобождаем память, занятую lesser и greater.
- quicksort(list, left, left + len(lesser))
- quicksort(list, left + len(lesser), right)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement