AlgoScope

Quick Sort

AlgorithmintermediateSorting

Pick a pivot, push everything smaller left, and the pivot is home for good.

Decision · step 3 of 29Quick Sort: Seven values
range 0-650114223843576jipivot5 < 7

5 is smaller than the pivot 7, so it belongs on the left.

Open in the player →or start at step 3

What you will see

CHOOSE PIVOT -> PARTITION (smaller left, larger right) -> pivot lands in its final place -> RECURSE.

How quick sort works →

Cost

BestO(n log n)
AverageO(n log n)
WorstO(n^2)
SpaceO(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.

Variants

  • Two-Way (Lomuto) Single boundary partition.
  • Hoare Partition Pointers converge from both ends.
  • Randomized Pivot Random pivot makes the worst case unlikely.

Leads to

Topics that need this one first.

Taught by the same lesson

Quick Sort covers these too, in the same run.