Quick Sort
Pick a pivot, push everything smaller left, and the pivot is home for good.
Decision · step 3 of 29Quick Sort: Seven values
5 is smaller than the pivot 7, so it belongs on the left.
What you will see
CHOOSE PIVOT -> PARTITION (smaller left, larger right) -> pivot lands in its final place -> RECURSE.
Cost
| Best | O(n log n) |
|---|---|
| Average | O(n log n) |
| Worst | O(n^2) |
| Space | O(log n) |
Space is recursion depth; O(n) worst case without tail-call on the larger side.
Properties
- ✓ comparison based
- × stable
- ✓ in place
- × adaptive
- × online
How you work with it here
play it through, step one change at a time, scrub to any step, run it on your own input, predict what happens next, compare two runs.
Screen readers: Cells announce index, value and state (comparing, swapped, sorted); each step announces the comparison outcome and any move.
Reduced motion: Swaps become value crossfades with outline flashes; sorted-region growth is a static span change.
Before this
Variants
- Two-Way (Lomuto) Single boundary partition.
- Hoare Partition Pointers converge from both ends.
- Randomized Pivot Random pivot makes the worst case unlikely.