"Greedy is the most seductive paradigm: grab the best-looking option right now and never look back. Sometimes that's provably optimal. Often it's confidently, silently wrong — and the danger is exactly that it looks right."
The Greedy Move
A greedy algorithm builds a solution by repeatedly making the choice that looks best at this moment, committing to it, and never reconsidering. It's fast, simple, and uses almost no memory. The catch: this only produces the globally optimal answer for problems with a special structure — the greedy-choice property, where a locally optimal choice is always part of some globally optimal solution. When that property holds, greedy is beautiful. When it doesn't, greedy gives a plausible-looking wrong answer.
When Greedy Provably Works
Several famous algorithms are greedy and provably optimal: activity selection (to attend the most non-overlapping meetings, always pick the one that finishes earliest), Huffman coding (merge the two least-frequent symbols), Kruskal's and Prim's MST (cheapest safe edge), Dijkstra (closest unfinalized node), and fractional knapsack (highest value-per-weight first). In each, there's a proof — usually an exchange argument showing any optimal solution can be rearranged to include the greedy choice without getting worse. The greediness isn't a gamble there; it's been verified.
When Greedy Lies
And here's the trap. Coin change with arbitrary coins: making 6 from {1, 3, 4}, greedy grabs 4 then 1 then 1 (three coins), but 3+3 is two. 0/1 knapsack (each item taken whole or not): greedily taking the highest value-per-weight can overlook a better combination. These problems lack the greedy-choice property, so the locally-best choice paints you into a corner. The lesson: greedy's speed makes it tempting to assume it's correct, but you must prove it (or test exhaustively) before trusting it — an unproven greedy is a bug waiting for the input that exposes it.