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.
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.
Jaro–Winkler similarity
Flag similar contact names for review. See how matching characters, transpositions, and a shared prefix change the score.
TypeScriptGoRustMyers 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.
TypeScriptGoRustAho–Corasick matching
Highlight a glossary of terms in one pass over a document. Follow shared prefixes and failure links, including overlapping matches.
TypeScriptGoRustBoyer–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.
TypeScriptGoRabin–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.
TypeScriptGoMinHash 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.
TypeScriptGoRoutes and connections
Find a way through, connect a whole network, or follow how influence flows.
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.
TypeScriptGoFloyd–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.
TypeScriptGoBellman–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.
TypeScriptGoA* 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.
TypeScriptGoKruskal’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.
TypeScriptGoPageRank
Rank pages in a tiny wiki by their incoming links. Follow repeated score updates and what happens to pages with no outgoing links.
TypeScriptGoMax 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.
TypeScriptGoStrongly connected components
Collapse mutually reachable modules in a dependency graph. Record finish order, reverse the arrows, and collect the cycles that belong together.
TypeScriptGoMatching and making choices
Make the objective explicit: total cost, stable preferences, or value within a limit.
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.
TypeScriptGoGale–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.
TypeScriptGo0/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.
TypeScriptGoWeighted 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.
TypeScriptGoQuickselect 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.
TypeScriptGoSweep-line interval overlap detection
Find overlapping release windows and peak concurrency by ordering boundary events once, with an explicit rule for intervals that touch.
TypeScriptGoChance and live data
Shuffle fairly, sample by weight, and summarize data that keeps arriving.
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.
TypeScriptGoReservoir 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.
TypeScriptGoAlias 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.
TypeScriptGoWelford’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.
TypeScriptGoImages, maps, and geometry
Make each decision visible in a line, a handful of pixels, or a changing image.
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.
TypeScriptGoConvex 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.
TypeScriptGoBresenham’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.
TypeScriptGoFloyd–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.
TypeScriptGoSeam 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.
TypeScriptGoRustSmaller data, steadier systems
Spend fewer bits, place keys predictably, and control how quickly work is admitted.
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.
TypeScriptGoLZ77 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.
TypeScriptGoRendezvous 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.
TypeScriptGoToken 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