Section Overview

  • Every technique below tackles the same core obstacle: an arbitrary “other solution” is hard to reason about directly, since we don’t know its structure.
  • All three ultimately establish (maximize) or (minimize) for every valid — they just get there by different routes.
  • Not every technique applies to every problem — picking the right one is itself part of the skill.

Exchange Argument (Modify-the-Solution)

Take an arbitrary solution that skips the greedy algorithm’s first choice , and show how to exchange one element of for to build a new solution that is still valid and at least as good. Then induct on instance size. See Event Scheduling for the full worked example.

  • General steps:
    1. State what’s known: the definition of , and that meets the problem’s constraints.
    2. Define from and — usually by swapping in for one element of .
    3. Prove is still valid, using the definition of .
    4. Compare ‘s value/cost to ‘s.
    5. Induct: assume greedy is optimal for all instances smaller than ; show for the size- case using the exchange result on the first choice, then the inductive hypothesis on the rest.
  • Key detail: inducts on the size of the input, not on the greedy algorithm’s own sequence of choices — this is what distinguishes it from Greedy Stays Ahead below.
  • Core inequality:

Greedy Stays Ahead

Instead of comparing just the first move, compare the entire greedy solution against an entire arbitrary solution , using a running progress measure — showing is always at least as far along as at every step. Induct on the greedy algorithm’s own choices, not the input size. See Event Scheduling for the full worked example.

  • General steps:
    1. Define a progress measure (e.g. “finish time of the chosen event”).
    2. Line up ‘s decisions with ‘s decisions in the same order.
    3. Prove by induction that ‘s progress after step is at least as good as ‘s.
    4. Assume by contradiction that is strictly better than .
    5. Use the progress argument to derive a contradiction.
  • Key detail: inducts on the index of the choice being made (-th greedy pick vs. -th choice in ), not on shrinking the problem size.
  • Core inequality: for all — if this held all the way through, having more events than would force an event to start after ‘s last pick finishes, which is a contradiction.

Achieves the Bound

Find a bound that (1) any valid solution must respect as a lower/upper limit, and (2) the greedy solution exactly reaches. This splits the proof into two separate, often-easier inequalities: , which together force optimal. See Event Scheduling with Multiple Rooms (Interval Partitioning) for the full worked example.

  • General steps:
    1. Identify a quantity every valid solution is forced to respect (e.g. “at least this many rooms, since this many events overlap at once”).
    2. Show that quantity is a genuine lower/upper bound for any solution.
    3. Show the greedy solution’s cost exactly equals that bound.
    4. Conclude (or the maximize analogue), so greedy is optimal.
  • Key detail: does not work for all problems — it requires a bound to exist that greedy provably hits exactly. Also comes up outside greedy algorithms entirely, in approximation algorithms, LP, and network flow.
  • Core inequality: , where is the bound (e.g. max simultaneous overlap) and are greedy’s and any-solution’s actual costs.

Quick Reference Table

TechniqueComparesInducts OnBest For
Exchange Argument vs. arbitrary , one element swappedInstance size (strong induction)Most general — try this first if unsure
Greedy Stays Ahead vs. arbitrary , step by stepThe greedy algorithm’s own sequence of choicesMore intuitive when there’s a natural running “progress” measure
Achieves the Bound vs. a bound vs. N/A — no induction, uses a bounding argument insteadOnly when a clean bound exists; also used in approximation algorithms, LP, network flow

References / Links