18 algorithms · Python, C++ and Java
Algorithm visualizations, step by step
Classic data structure and algorithm problems, each explained and ready to run. Open one and watch the real program execute — the array being sorted, the pointers moving, the call stack growing — one line at a time.
01Sorting & searching
- Bubble SortBubble sort walks the array again and again, swapping neighbours that are out of order, until everything is in place.
- Insertion SortInsertion sort works the way most people sort a hand of cards: take the next card and slide it left until it sits in order.
- Binary SearchBinary search finds a value in a sorted array by checking the middle and throwing away the half that cannot contain it.
02Recursion, stacks & hash maps
- Recursive FibonacciRecursion is hard to follow on paper because the interesting part — the stack of calls waiting for answers — is invisible.
- Valid ParenthesesChecking whether brackets are balanced (LeetCode 20) is the classic first stack problem.
- Two SumTwo Sum (LeetCode 1) asks for two positions whose values add up to a target.
03Linked lists
04Trees
- Binary Search TreeA binary search tree keeps every value in a node’s left subtree smaller than it, and every value in its right subtree larger.
- Maximum Depth of Binary TreeFinding the depth of a binary tree (LeetCode 104) is the cleanest example of a recursive function that builds its answer on the way back up.
- Binary Tree TraversalsInorder, preorder and level-order traversals visit the same nodes; only the order differs.
05Graphs
- Breadth-First Search (BFS)Breadth-first search explores a graph in rings: the start vertex, then everything one edge away, then everything two edges away.
- Depth-First Search (DFS)Depth-first search follows one path as far as it goes, then backs up to the most recent fork and tries the next branch.
- Dijkstra’s AlgorithmDijkstra’s algorithm finds the cheapest route from one vertex to every other in a graph whose edge weights are not negative.
06Dynamic programming
- Climbing StairsIf you can climb one or two steps at a time, how many different ways are there to reach step n? It is Fibonacci in disguise, and the gentlest introduction to dynamic programming.
- Coin ChangeCoin change (LeetCode 322) asks for the fewest coins that add up to an amount.
- 0/1 KnapsackGiven items with weights and values and a bag with a weight limit, which items give the most value? Each item is either taken whole or left behind — hence 0/1.
- Longest Common SubsequenceThe longest common subsequence of two strings is the longest run of characters that appears in both in the same order, though not necessarily side by side.
Not on the list?
Any program you write runs in the visualizer. Paste it in and watch it go.