Learn algorithms: 20 free interactive lessons
Short lessons where every idea is an animation you step through: searching, Big-O, sorting, stacks and queues, hash tables, heaps, trees, graphs, recursion and dynamic programming.
Do it in the browser: a real algorithms tool, a short mission and instant feedback. No install. Optional certificate at the end of the course.
Open the courseLessons
- Searching one by oneAn algorithm is a precise recipe. The simplest one: look at every item until you find the one you want.
- Big-O: how work growsCompare algorithms by how their cost grows with the input size, not by seconds on one computer.
- Binary searchOn a sorted list, check the middle and throw away half. 1,000,000 items need about 20 looks.
- Two pointersFind a pair that adds up to a target in one pass, instead of checking every pair.
- Bubble sortCompare neighbours and swap: big values bubble to the end.
- Insertion sortLike sorting cards in your hand: take the next one and slide it into place.
- Merge sortSplit the list in halves, sort each half, merge the sorted halves.
- QuicksortPick a pivot, put smaller values left and bigger right, repeat on each side.
- StacksLast in, first out: undo, the call stack and balanced brackets.
- QueuesFirst in, first out: tasks, messages and fair waiting.
- Hash tablesTurn a key into a position and find things in O(1) on average.
- Heaps and priority queuesAlways know the smallest item, even while items keep arriving.
- Binary search treesSmaller to the left, bigger to the right: binary search that can grow.
- Walking a treePre-order, in-order and post-order: three ways to visit every node.
- Breadth-first searchExplore in rings around the start to find the shortest path in steps.
- Depth-first searchGo as deep as possible, back up at dead ends: backtracking.
- Dijkstra's shortest pathsWhen roads have different lengths, always expand the closest unfinished place.
- RecursionA function that calls itself on a smaller problem, and the cost of repeating work.
- Dynamic programmingSolve each small problem once, store it, build the big answer from the table.
- Greedy algorithmsTake the best-looking choice now. Sometimes perfect, sometimes a trap.