0

Algorithm race

Run two algorithms on the same input, one step at a time, and watch where the work actually goes.

All visualisers
Classic matchups
1 / 48
Bubble SortO(n^2), best O(n) when already sorted1 / 48
Quick SortO(n log n) average, O(n^2) worst1 / 28
Quick Sort finishes in 28 steps, 1.7x fewer than Bubble Sort.Steps are animation frames, so they track comparisons and visits rather than nanoseconds.
Bubble Sort
O(n^2), best O(n) when already sorted · O(1)
E1/48
5
0
1
1
4
2
2
3
8
4
0
5
2
6
comparisons 0swaps 0

Starting array. Nothing is known to be in place yet.

Open on its owncomparison sort · stable
Quick Sort
O(n log n) average, O(n^2) worst · O(log n) stack
M1/28
5
0
1
1
4
2
2
3
8
4
0
5
2
6
comparisons 0swaps 0

Partition around a pivot, then recurse into both sides.

Open on its owndivide and conquer · in place