ƒ(x) SortingIntermediate interactive
Quick Sort
Partition around a pivot, recurse on each side.
quick_sort
step 1 / 61
44
8
18
20
88
94
64
34
50
94
94
Pick a pivot (last element); partition around it.
comparingmovingpivotsorted
speed1×
How it works
Quick sort picks a pivot, partitions elements into smaller-than and larger-than groups, then recurses. In practice it's the fastest comparison sort thanks to in-place partitioning and cache friendliness — averaging O(n log n), with an O(n²) worst case tamed by good pivot choice.
Mental models
- Partitioning places the pivot in its final sorted position.
- Randomized or median-of-three pivots avoid the O(n²) trap.
Complexity
- Best
- O(n log n)
- Average
- O(n log n)
- Worst
- O(n²)bad pivots
- Space
- O(log n)recursion stack