Back to Algorithms & Data Structures
Algorithms & Data Structures·Algorithms··

Greedy

Build a global solution from locally optimal choices when the problem's structure makes those choices safe.

Algorithm Summary

A greedy algorithm chooses the best-looking option at each stage with the goal of reaching a global optimum. Try a greedy approach when a locally optimal choice appears to preserve the best possible future outcome and you cannot construct a counterexample.

The implementation is often short; the difficult part is the proof. Look for an exchange argument, an invariant, or a way to show that delaying the locally optimal choice can never improve the final result.

Back to Algorithms & Data Structures