CPKit
v1.6.1

The Greedy Method Paradigm

Greedy algorithms build up a solution piece by piece, always choosing the next piece that offers the most obvious and immediate local benefit. To prove its correctness, it must satisfy:

  • Greedy Choice Property: A globally optimal solution can be reached by making locally optimal (greedy) choices.
  • Optimal Substructure: An optimal solution to the global problem contains optimal solutions to subproblems.

How to Prove Greedy Correctness

Unlike Dynamic Programming which checks all subproblems, Greedy makes a single irrevocable decision. Proofs of correctness generally use:

  • Exchange Arguments: Show that any optimal solution can be converted into the greedy solution without losing quality.
  • Greedy Stays Ahead: Show that at each step of the algorithm, greedy is at least as good as any other choices pattern.