Watch nine sorting algorithms think through the same numbers. Pause at a comparison, step back, or race two approaches to see why their work differs.
Try 42, 7, 19, 3, 88 with Bubble sort. Step forward to watch neighbouring values trade places. Then race it against Quicksort.
Every algorithm runs on the exact array shown on the bench above. Change the input shape or size and this table re-measures. Select a row to load that algorithm.
| # | Algorithm | Comparisons | Swaps | Writes | Total work | Relative work (log scale) | Average case |
|---|
The algorithms never touch the screen. They run to completion first, and the page plays back what they did.
Each algorithm sorts a copy of the array through a tracer that logs every compare, swap and write, plus the pseudocode line it came from.
{ t: 's', i: 4, j: 5, l: 6 }
The canvas replays the log at whatever speed you pick. Because the log is fixed, playback runs forwards or backwards equally well.
A snapshot is stored every 512 operations, so any point on the timeline is at most 512 replays away. Bubble sort on 256 bars is about 50,000 operations and still scrubs instantly.