Partition
Push everything smaller than the pivot to its left, then drop the pivot between the groups.
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
The pivot is pinned; a boundary pointer grows the "smaller" region with each swap.
Cost
| Best | O(n) |
|---|---|
| Average | O(n) |
| Worst | O(n) |
| Space | O(1) |
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.
Screen readers: Each cell is announced as index, value and state; each step's accessibility text states the decision and its effect.
Reduced motion: Swaps and shifts become value crossfades with an outline flash; pointers appear at their destination.
Before this
Variants
- Lomuto Partition Single scan with a boundary index.
- Hoare Partition Two pointers converge from both ends.