iolinked
iolinked · algorithms, from the constraint up

An algorithm isn't a trick.
It's what the constraint forces.

There are a thousand places to grind algorithm problems, and nearly all of them hand you the same thing: a catalogue of patterns and the advice to recognise which one fits. That works right up until you meet a problem nobody catalogued. This course does the opposite. Every page opens with something you are not allowed to do — you can't try every candidate, you can't see the future, you can only ask one vertex who its neighbours are — and then works out what that leaves you. The algorithm arrives as the only move left, not as a name to memorise. Six pages carry the ideas and fourteen carry the tools, each one opening with more than twenty situations where you'd actually reach for it. You'll leave able to re-derive the thing you forgot, price it before writing a line, and say out loud what your bound does and does not promise — which is the part an interview is really testing, and the part a pattern list can never give you.

01

Browse the course

five parts · 20 pages · six ideas, fourteen tools
Part I · 6 pages

The six constraints

The ideas that carry the whole subject — cost, repeated work, the channel, the adversary, the one-vertex view, and the problems with no fast answer.

Start here
Part II · 5 pages

Lookup & order

Computing the index instead of searching for it — hashing, sorting as a pre-move, binary search, heaps, and prefix sums.

Open
Part III · 4 pages

Graphs

One primitive under four different orderings — fewest hops, dependency order, cheapest path, and connectivity.

Open
Part IV · 3 pages

Strategy

Deciding what to compute and when — tables that reuse work, choices you can prove safe, and work you defer until it's cheap.

Open
Part V · 2 pages

Selection & memory

Getting the answer without sorting everything, and deciding what to keep when you can't keep it all.

Open
Live now · 15 interactives

Start: you can't try everything

A machine a thousand times faster, hand-written machine code, the best programmer alive — and it still loses by 17×. Try to find a machine speed that saves it.

Read page 1
02

Part I · The six constraints

6 pages · the ideas, each one a limit and what it forces
algorithms — part I · the six constraints
03

Part II · Lookup & order

5 pages · compute the index instead of searching for it
algorithms — part II · lookup & order
04

Part III · Graphs

4 pages · one primitive under four orderings
algorithms — part III · graphs
>>>
pg 12BFS & Fewest HopsA queue turns "who is nearest" into a wavefront — and the moment edges carry weights, the queue stops being enough.soon pg 13Topological Sort & Cycle DetectionAnything with prerequisites is a graph. An order exists exactly when no cycle does, and the failure tells you where the deadlock is.soon pg 14Dijkstra & the Cheapest PathSwap the queue for a heap and fewest-hops becomes cheapest-cost — plus the one assumption that breaks it.soon pg 15Union-Find"Are these two in the same group?" answered in almost constant time, by a structure that tidies itself while you ask.soon
05

Part IV · Strategy

3 pages · what to compute, and when
algorithms — part IV · strategy
>>>
pg 16Dynamic ProgrammingPrice it before you code it: distinct subproblems × choices each. And the one legality test — subproblems must not compete for a shared resource.soon pg 17Greedy & the Exchange ArgumentChoose first, then solve what's left. Pick the key by what the choice leaves behind — and license it with one exchange, or don't ship it.soon pg 18Amortised DesignDoubling, hysteresis, and deferred work: why a rare expensive operation can still be cheap, and why every threshold needs a deadband.soon
06

Part V · Selection & memory

2 pages · ask for less, and keep less
algorithms — part V · selection & memory
>>>
pg 19Quickselect, Top-k & PercentilesRecurse one side instead of two and the logarithm disappears — the median for the price of a scan.soon pg 20Caching & EvictionEvery cache is a bet about the future. What you evict is the bet — and the hit rate is how you find out you were wrong.soon