Applied algorithms

Once by the book.
Once for a problem you recognize.

A misspelled name still finds its match. A route bends around a wall. An image gets narrower along a winding path of pixels. Explore the algorithms that make these things possible, the ideas they build on, and the limits of their answers.

Moving in. 34 of 34 topics have lessons; they're moving over from the old site.

34 topics

Moving in 34 of 34 topics have lessons, which are moving over from the old site. Planned topics show where the catalog is going.

Text, names, and changes

Find what almost matches, what changed, and where a whole set of words appears.

Algorithm moving

Jaro–Winkler similarity

Flag similar contact names for review. See how matching characters, transpositions, and a shared prefix change the score.

TypeScriptGoRust
Algorithm moving

Myers diff

Turn two versions of a caption transcript into line additions and removals. Find a shortest edit script, then see why ties affect what a diff looks like.

TypeScriptGoRust
Algorithm moving

Aho–Corasick matching

Highlight a glossary of terms in one pass over a document. Follow shared prefixes and failure links, including overlapping matches.

TypeScriptGoRust
Algorithm moving

Boyer–Moore substring search

Find one exact marker in long text by comparing from the right and skipping safe distances with bad-character and good-suffix tables.

TypeScriptGo
Algorithm moving

Rabin–Karp rolling-hash search

Find one exact line in a longer text with a rolling hash, then verify equal-hash windows so collisions never become false matches.

TypeScriptGo
Algorithm moving

MinHash and locality-sensitive hashing

Find likely near-duplicate documents before comparing every pair. Turn word shingles into compact MinHash signatures, then use locality-sensitive hashing to surface candidates for exact review.

TypeScriptGo

Routes and connections

Find a way through, connect a whole network, or follow how influence flows.

Algorithm moving

Dijkstra’s shortest path

Find the quickest walk across a campus with minutes on every path. Settle the nearest place, offer its neighbors a time, see why a settled time is final, and rebuild the route when two tie. Routers running OSPF use the same algorithm.

TypeScriptGo
Algorithm moving

Floyd–Warshall all-pairs shortest paths

Fill a distance matrix for every ordered pair. Allow each node as an intermediate, remember next hops for route reconstruction, and reject negative cycles instead of inventing finite answers.

TypeScriptGo
Algorithm moving

Bellman–Ford shortest paths

Find the cheapest chain of currency conversions when a quote can beat the mid-market rate: relax every quote repeatedly, let later improvements travel, and name an arbitrage loop instead of quoting it.

TypeScriptGo
Algorithm moving

A* pathfinding

Point Dijkstra’s search at the goal: expand the smallest moves-so-far plus an estimate. See why Manhattan distance keeps tile-map routes shortest, what doubling it gives up, and a tower-defense wall check.

TypeScriptGo
Algorithm moving

Kruskal’s minimum spanning tree

Connect a festival site with the least cable: lay the shortest runs that join two groups, skip the ones that close a loop, keep last year’s cable, and name what no run can reach.

TypeScriptGo
Algorithm moving

PageRank

Rank pages in a tiny wiki by their incoming links. Follow repeated score updates and what happens to pages with no outgoing links.

TypeScriptGo
Algorithm moving

Max flow and min cut

Move the greatest number of appointments through capacity-limited clinic lanes. Find augmenting paths, keep residual capacity, and read the cut that proves the total is full.

TypeScriptGo
Algorithm moving

Strongly connected components

Collapse mutually reachable modules in a dependency graph. Record finish order, reverse the arrows, and collect the cycles that belong together.

TypeScriptGo

Matching and making choices

Make the objective explicit: total cost, stable preferences, or value within a limit.

Algorithm moving

Hungarian assignment

Assign each delivery robot to one pickup with the least total travel cost. See why taking the cheapest available pair can miss the best assignment.

TypeScriptGo
Algorithm moving

Gale–Shapley stable matching

Pair learners and mentors who rank each other so no pair would walk away: follow proposals, held offers, and trade-ups, see who gains from proposing, and check a match before publishing it.

TypeScriptGo
Algorithm moving

0/1 knapsack

Choose which offline downloads fit a storage budget. Give each item a size and value, then compare taking it with leaving room for something else.

TypeScriptGo
Algorithm moving

Weighted interval scheduling

Choose a day of conference talks with the highest total interest score and no overlaps. An appealing long talk might displace four better short ones.

TypeScriptGo
Algorithm moving

Quickselect percentile selection

Find one percentile or median in a batch without sorting every value. Partition around a pivot, discard the impossible side, and make the rank policy explicit.

TypeScriptGo
Algorithm moving

Sweep-line interval overlap detection

Find overlapping release windows and peak concurrency by ordering boundary events once, with an explicit rule for intervals that touch.

TypeScriptGo

Chance and live data

Shuffle fairly, sample by weight, and summarize data that keeps arriving.

Algorithm moving

Fisher–Yates shuffle

Shuffle a playlist so every order has the same chance. Count why sorting with a random comparator and swapping with any position are unfair, then keep one order across server and browser.

TypeScriptGo
Algorithm moving

Reservoir sampling

Keep five support tickets from a day nobody can count in advance, so every ticket has the same chance: fill the slots, draw below the ticket’s number, count every draw to prove it, and catch the off-by-one.

TypeScriptGo
Algorithm moving

Alias method

Build a weighted loot table for a game. Rearrange the probabilities once, then choose each reward with a table lookup and a coin flip.

TypeScriptGo
Algorithm moving

Welford’s online variance

Keep a barometer’s hourly mean and spread in three numbers: move the mean, add the old distance times the new one, merge summaries from many stations, and see the textbook formula go negative.

TypeScriptGo

Images, maps, and geometry

Make each decision visible in a line, a handful of pixels, or a changing image.

Algorithm moving

Ramer–Douglas–Peucker simplification

Simplify a sketched route by keeping only points that stray past a tolerance. Drag the tolerance and watch bends survive or disappear; after a quick distance filter, the same algorithm simplifies every Leaflet polyline by default.

TypeScriptGo
Algorithm moving

Convex hull

Wrap a park survey in its smallest convex boundary. Sort the points, pop inward turns, and separate the outside envelope from measurements inside it.

TypeScriptGo
Algorithm moving

Bresenham’s line algorithm

Draw a crisp line in a pixel-art editor: a whole-number error term decides, with additions only, when the next cell steps across, down, or both, with a canvas line tool that sets whole pixels.

TypeScriptGo
Algorithm moving

Floyd–Steinberg dithering

Turn a shaded picture into black dots for a label printer: round each pixel and hand the difference to its neighbors, with a browser preview that shows exactly what will print.

TypeScriptGo
Algorithm moving

Seam carving

Narrow a picture by removing a winding path of low-energy pixels. Inspect the energy map and discover when its idea of importance distorts the subject.

TypeScriptGoRust

Smaller data, steadier systems

Spend fewer bits, place keys predictably, and control how quickly work is admitted.

Algorithm moving

Huffman coding

Give common bytes shorter codes in a test runner’s progress line: count, merge the two lightest trees, read canonical codes from their lengths, and see when the table costs more than it saves.

TypeScriptGo
Algorithm moving

LZ77 compression

Compress a JSON API response by replacing repeated bytes with copies from earlier. Decode a copy that overlaps itself, count what it saves against real gzip, and gzip an upload in the browser.

TypeScriptGo
Algorithm moving

Rendezvous hashing

Place photos on a cache tier by giving every server a score for every key. Take a server away or add one and only the keys that must move do; keep two copies and plan a server’s exit.

TypeScriptGo
Algorithm moving

Token bucket

Give each API key a burst it can spend and a pace it earns back. Admit or reject on a controllable clock, and answer 429 with a Retry-After that tells the client when to come back.

TypeScriptGo