Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- counter = 0
- def quick_sort(data):
- global counter
- counter += 1
- if len(data) > 1:
- x = data[random.randint(0, len(data) - 1)]
- low = [u for u in data if u < x]
- eq = [u for u in data if u == x]
- hi = [u for u in data if u > x]
- data = quick_sort(low) + eq + quick_sort(hi)
- return data
- a = []
- for _ in range(100):
- a.append(random.randint(-2349330, 2349330))
- a = quick_sort(a)
- print(a)
- print(counter)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement