← Back to All Algorithms

🎲 Randomized Quicksort

Why Randomize?

Problem: Standard Quicksort is O(n²) on sorted input (always picks worst pivot).

Solution: Pick a random pivot! This gives expected O(n log n) regardless of input order.

Comparisons
0
Swaps
0
Click "Start" — uses randomly chosen pivot each partition!

Sorted Input + Fixed Pivot

O(n²) worst case

Any Input + Random Pivot

Expected O(n log n)