Skip to content

Glossary: Algorithms Beyond the Basics in C++

Greedy algorithm

Also written: greedy, greedy choice

An approach that takes the best-looking choice at each step and never undoes it. It is fast but only correct when something like a swap argument shows the choice is safe; it fails for $10, $25 and $30 gift cards.

Where the book teaches it

Related terms

swap argument