Greedy Algorithm¶
Core Idea¶
Commit to the locally best available choice at each step, irrevocably, with no lookahead and no backtracking. The pattern is interesting for its sharp dichotomy: on matroid-shaped problems greedy is provably optimal; otherwise it locks into local optima a little foresight would have avoided.
How would you explain it like I'm…
Grab the Biggest Now
Best-Right-Now, No Takebacks
Local Best, No Lookahead
Broad Use¶
- Computer science: minimum spanning trees (provably optimal), Huffman codes, Dijkstra's algorithm, greedy set cover (a logarithmic-factor approximation).
- Behavioral economics: hyperbolic discounting and the marshmallow test — taking the locally best immediate payoff and forfeiting larger delayed ones.
- Evolution: incremental fitness optimization that locks populations onto local peaks — selection without lookahead.
- Policy: electoral-cycle policy that optimizes myopically per term, forfeiting long-term obligations.
- Bureaucracy and triage: queue-by-loudest-complaint and deal-with-the-closest-deadline.
- Machine learning: greedy decision-tree induction and greedy sequence decoding versus beam search.
Clarity¶
Makes the commitment-irrevocability of each step explicit and separates "the local score is wrong" from "greedy is wrong for this problem shape" — the single biggest clarifying move, since greedy is provably optimal where the structure permits.
Manages Complexity¶
Compresses the decision policy to one locally evaluable function and dispenses with state; when greedy fails, the diagnosis is compact — find the door-closing step, then widen the score, add lookahead, or restructure the problem.
Abstract Reasoning¶
The matroid criterion tests whether local-best concatenates to global-best; the single counter-example "give up a local best to enable a larger global gain" is the canonical failure shape, and random restart is a portable escape patch.
Knowledge Transfer¶
- Algorithms → life: the matroid criterion explains why accumulating independent course credits suits local preferences while saving a down payment demands foresight.
- Evolution → culture: populations stay stuck on local peaks until drift supplies the randomization a greedy process needs to escape — the same fact in cultural norm-evolution.
- Behavior → policy: commitment devices, defaults, and auto-escalators are the human analogue of constraints that stop greedy from closing a needed door.
Example¶
A salesperson's call list greedily sorted by smallest immediate effort fails when large accounts need multi-touch sequences the per-step rule undervalues — and the same three-part fix (change the score, add lookahead, add restart) that patches it also patches a greedy investment policy.
Relationships to Other Abstractions¶
Current abstraction Greedy Algorithm Prime
Parents (1) — more general patterns this builds on
-
Greedy Algorithm is a kind of Heuristic Prime
'Not heuristic in general — greedy is a specific heuristic schema (local-best, irrevocable, no-backtrack) with a sharp optimality theorem (matroids) most heuristics lack.' A specialization of heuristic.
Children (1) — more specific cases that build on this
-
Greedy coloring Domain-specific is a kind of Greedy Algorithm
The proposed strict upward parent is
prime:greedy_algorithm.
Hierarchy paths (2) — routes to 2 parentless roots
- Greedy Algorithm → Heuristic → Approximation → Representation → Abstraction
- Greedy Algorithm → Heuristic → Trade-offs → Constraint
Not to Be Confused With¶
- Greedy Algorithm is not Dynamic Programming because greedy uses only present local evaluation with no memo table, whereas dynamic programming stores and recombines subproblem solutions to discover that a locally-suboptimal move enables a globally-optimal whole.
- Greedy Algorithm is not a Local Optimum because a local optimum is a state (a point no neighbor improves), whereas greedy is the procedure that characteristically lands in one.
- Greedy Algorithm is not Satisficing because satisficing stops at the first good-enough option against a threshold, whereas greedy always takes the locally best and runs to completion.