Sort Target
Algorithm
Speed
Normal ~12s · 96 ms/step
Quicksort (Median9)(1993)
▶ Try this Source
O(n log n) ✗ Stable ✓ In-place
🔧 How it works

Samples nine elements from three equally spaced groups of three, takes the median of each group, then takes the median of those three medians as the pivot before partitioning.

🎯 Key property

Nine samples approximate the true median far better than three, producing more balanced partitions and fewer total comparisons on large arrays, at the cost of nine extra reads per partition step.

👁 Watch for
  • IndexRead nine elements are sampled, three group medians are computed, and the median-of-medians is chosen as the pivot; watch the extra reads before the partition scan begins
  • Compare same left-right partition scan as basic Quicksort; the better-chosen pivot typically produces more even splits
  • Swap same as basic Quicksort, elements on the wrong side are swapped across the partition boundary
Initial State
This is the array before sorting. Follow Quicksort (Median9) step by step.
Recursion Tree
[0..9)371952846
0 / 125 ops ( 0.0%) 0.0%
Sorting is
a spectacle.
Algorithms at work, in a daily vertical feed. Watch, play, challenge — and go deeper when you're ready.
Loading 0%
An unhandled error has occurred. Reload 🗙