Algorithms

Classic algorithms and data structures visualized step by step — shortest paths, balanced trees, and the sketches that trade exactness for space.

01
DIJKSTRA'S ALGORITHM
Greedy shortest paths, and the one assumption that makes greedy safe
L215 MIN
02
A* SEARCH
Dijkstra with a compass, and what happens when the compass lies
L215 MIN
03
UNION-FIND
Nearly O(1) connectivity queries via path compression and union by rank
L215 MIN
04
RED-BLACK TREE
Four colour rules that keep a binary search tree from turning into a list
L318 MIN
05
B-TREE
Fat, shallow nodes that grow from the root, one page read per level
L215 MIN
06
CONSISTENT HASHING
Add a node and only about K/(N+1) keys move
L216 MIN
07
BLOOM FILTER
Probably yes, definitely no: set membership in a few bits per key
L215 MIN
08
HYPERLOGLOG
Count distinct items in kilobytes, whatever the cardinality
L318 MIN
09
COUNT-MIN SKETCH
Approximate frequency counts that never undercount
L215 MIN
10
SKIP LISTS & TRIES
Two ways to search without a balanced tree
L215 MIN
11
TIMER WHEELS
A million timeouts without a million-entry heap
L215 MIN
12
CAPSTONE: TOP-K IN A STREAM
Everything in this path, in one trending-topics service
L320 MIN
13
FX ARBITRAGE
A loop of rates that multiplies past 1 is a negative cycle
L216 MIN