← Greedy · guided lesson

Greedy Algorithms

1 / 21 · story

the story

The greedy method

Every tool here exists because something was too slow or broke without it. Here is what.

1956–1971 · Joseph Kruskal; Richard Rado; David Gale; Jack Edmonds

Greedy rules were in use before anyone could say when they work. Kruskal's 1956 minimum spanning tree adds the cheapest safe edge, again and again. Rado (1957), Gale (1968) and Edmonds (1971) found the clean answer for one big family of problems: "take the best remaining item that still fits" is optimal for every choice of weights exactly when the structure is a matroid. Edmonds' paper "Matroids and the greedy algorithm" is the classic reference. For everyday interview problems, you prove each greedy rule by hand instead: exchange argument or stays ahead.

the problem it solved

Knowing in advance when "always take the best remaining item" is guaranteed to be optimal, instead of hoping.

why it matters: without it

Many scheduling and selection problems would need DP or brute force: O(n²) or worse, where one sort and one pass would do.

sources: Kruskal — On the shortest spanning subtree of a graph and the traveling salesman problem (Proc. AMS, 1956) ↗ · Rado — Note on Independence Functions (Proc. London Math. Soc., 1957) ↗ · Gale — Optimal assignments in an ordered set: An application of matroid theory (J. Combinatorial Theory, 1968) ↗ · Edmonds — Matroids and the greedy algorithm (Mathematical Programming, 1971) ↗

also in this chapter: Proving greedy: exchange argument & stays ahead · Furthest reach (BFS on a line without a queue) · Change-making: where greedy breaks