Sorting and pathfinding, one step at a time
Understand algorithms. Don't memorise them.
Eleven classic algorithms you can watch, pause and step through line by line, each explained in plain language with the places you meet it in real life.
Insertion sort0 comparisons · 0 writes
01
Watch it run
Play, pause, scrub and change the speed. Every step is recorded, so you can go backwards too.
02
Follow the code
The pseudocode highlights the line that just ran, with the live values of every variable.
03
Check yourself
Each algorithm ends with a question that tests whether you understood it, not whether you remember it.
Sorting
Open visualiser →Seven ways to put values in order. Compare two on the same input and see how many comparisons, swaps and writes each one needs.
- Bubble sortRepeatedly walks the array swapping neighbours that are out of order until a full pass makes no swaps.O(n²)
- Insertion sortBuilds a sorted prefix one item at a time by sliding each new item left into its correct spot.O(n²)
- Selection sortRepeatedly finds the smallest remaining value and swaps it into the next position.O(n²)
- Merge sortSplits the array in half, sorts each half recursively, then merges the two sorted halves.O(n log n)
- Quick sortPicks a pivot, partitions values into smaller and larger sides, then sorts each side recursively.O(n log n)
- Heap sortBuilds a max-heap from the array, then repeatedly moves the largest value to the end and repairs the heap.O(n log n)
- Radix sort (LSD)Sorts integers digit by digit, starting from the least significant digit, using a stable bucket pass for each digit.O(d(n + b))
Pathfinding
Open visualiser →Four ways to search a grid. Draw walls and costly terrain, generate a maze, and watch how each search spreads.
- Breadth-First SearchExplores the grid in rings, visiting every cell at distance 1, then 2, and so on, until it reaches the goal.O(V + E)
- Depth-First SearchFollows one direction as far as it can, then backtracks to the last branch point and tries another.O(V + E)
- DijkstraFinds the lowest-cost path by always expanding the unvisited cell with the smallest known total cost.O((V + E) log V)
- A*Finds the lowest-cost path by expanding the cell with the smallest cost-so-far plus estimated distance to the goal.O((V + E) log V)