Algorithm Visualiser
Give an algorithm your own data and watch it work, one step at a time, with the line of code responsible highlighted beside it and a sentence explaining every move.
Run them side by side
Pick a group and every algorithm in it runs the same input in step. The counters under each one turn the difference between them into a number instead of an impression.
All six sorts running on the same shuffled array. Press play and watch the comparison counts separate: the n log n sorts finish while the others are still halfway.
At n = 14, the curves on the cards are worth n log₂n ≈ 53 and n² = 196. The counters are exact counts for this one run, so a count can sit above its own curve — that gap is the constant factor Big-O drops. Pull the size slider and watch which counters keep up.
- Bubble Sortstep 1AverageO(n²)
- Comparisons
- 0
- Writes
- 0
- for scale
- n² = 196
Sort 14 bars by repeatedly swapping neighbours that are the wrong way round.
- Selection Sortstep 1AverageO(n²)
- Comparisons
- 0
- Writes
- 0
- for scale
- n² = 196
Find the smallest bar left, put it next, repeat.
- Insertion Sortstep 1AverageO(n²)
- Comparisons
- 0
- Writes
- 0
- for scale
- n² = 196
Grow a sorted run on the left, inserting one bar into it at a time.
- Merge Sortstep 1AverageO(n log n)
- Comparisons
- 0
- Writes
- 0
- for scale
- n log₂n ≈ 53
Split the array down to single bars, then merge the pieces back in order.
- Quicksortstep 1AverageO(n log n)
- Comparisons
- 0
- Writes
- 0
- for scale
- n log₂n ≈ 53
Pick a pivot, move everything smaller to its left, then sort each side.
- Heap Sortstep 1AverageO(n log n)
- Comparisons
- 0
- Writes
- 0
- for scale
- n log₂n ≈ 53
Read the array as a binary tree: the children of index i are at 2i+1 and 2i+2. Build a max-heap, then take the top repeatedly.
All 17 visualisers
Each one has its own page, with the full-size picture, the code, controls for building your own input, and a written explanation of what it is doing and why.
Sorting
Six ways to put the same bars in order. The counters are the point: they turn “n² is worse than n log n” into a number you can watch grow.
- Bubble SortSwap neighbours that are the wrong way round, over and over.
- Selection SortFind the smallest value left, swap it into place, repeat.
- Insertion SortGrow a sorted run on the left, inserting one value at a time.
- Merge SortSplit down to single values, then merge the pieces back in order.
- QuicksortPartition around a pivot, then sort each side.
- Heap SortBuild a max-heap inside the array, then take the top repeatedly.
Searching
Finding one value in an array. Sorting first costs something, and these show exactly what it buys you.
Pathfinding
Four searches across a grid you draw yourself. They differ in one line — which cell comes out of the waiting list next — and that line changes everything.
Data structures
Build up a sequence of operations and watch the structure respond to each one, with the cost of every operation shown as it happens.