Practice
Write the classics yourself in Python, JavaScript or TypeScript. Your code runs in your browser and drives the same visualiser as the built-in version, next to your own lines.
Write it
Order the lines, fill the gaps, then write it whole
- Sorting · 3 stagesWrite bubble sortSort an array by swapping neighbours that are out of order, and watch your own code do it.
- Sorting · 3 stagesWrite insertion sortGrow a sorted prefix by sliding each new element left into place.
- Sorting · 3 stagesWrite selection sortFind the smallest remaining element and swap it into the next place.
- Searching · 3 stagesWrite binary searchFind a value in a sorted array by halving the search window each time.
- Dynamic Programming · 3 stagesCount the paths through a gridCount the paths across a grid by filling a table, and watch each cell add up the two cells it is reached from.
- Graph · 3 stagesWrite breadth-first searchFind how many edges each node is from the start, ring by ring, and watch your own queue drive the graph.
- Graph · 3 stagesWrite depth-first searchGo as deep as you can before backing up, and watch your own calls pile up on the graph.
- Hierarchical · 3 stagesInsert into a binary search treeWalk down a search tree to the empty spot where a new value belongs, and watch your new node get linked in.
- Hierarchical · 3 stagesWrite an inorder traversalList a tree’s values left subtree, node, right subtree, and watch your recursive calls walk it.
- Calculus · 2 stagesBackpropagate through a neuron by handWork out how a neuron’s output changes with each weight and its bias, with nothing but the chain rule.
- Calculus · 2 stagesGive each operation its local gradientFill in the backward step of +, × and tanh in a tiny autograd engine, and let it differentiate whole expressions.
- Calculus · 2 stagesRun backpropagation in the right orderWrite backward(): sort the graph so every value comes after its inputs, then pass gradients back from the output.
Change it
Start from working code and make it do something new
Find the bug
Run it, watch where it goes wrong, fix it
- Bug huntFix the crashing bubble sortThis bubble sort crashes on its first pass. Watch where, and fix it.
- Bug huntFix the binary search that never finishesSearching for some values never ends. Find the window that stops shrinking.
- Bug huntFix the insertion sort that loses valuesValues vanish and others appear twice. Catch the moment one is overwritten.