Pick two algorithms, set an input array, and watch them run simultaneously. Same data, same controls — see exactly how many steps each one takes.
Space to play/pause · ← → to step
Bubble SortO(n²)
Step 1 / 51
6
0
3
1
8
2
1
3
9
4
2
5
7
6
4
7
Bubble sort walks the array comparing each pair of neighbors. The biggest value keeps getting pushed to the right, like a bubble rising to the top.
Quick SortO(n log n) avg
Step 1 / 31
6
0
3
1
8
2
1
3
9
4
2
5
7
6
4
7
Quick sort picks a pivot element, partitions the array so everything smaller is left of the pivot and everything larger is right, then recursively sorts each side. Average case is O(n log n) with O(1) extra space.