Unit content
Greedy algorithms
A greedy algorithm builds a solution by repeatedly making the locally best available choice and never revisiting earlier decisions.
The strategy is appropriate only when local choices can be shown to lead to a globally optimal solution.
A typical proof uses an exchange argument: compare an optimal solution with the greedy one and show that an early choice can be replaced by the greedy choice without making the solution worse. Repeating this transformation establishes optimality.
Greedy algorithms are often simple and fast, but the strategy is not universally valid. A plausible local rule can fail when an early decision blocks a better combination later.
Examples include interval scheduling, minimum spanning tree algorithms and some shortest-path settings.