AlgoScope

Greedy

Take the locally best choice and never look back. Correct only when an exchange argument holds.

Algorithmic paradigms, paradigm, intermediate
With 6 left, the largest coin that fits is 4. Take it once, leaving 2.403112coin
With 6 left, the largest coin that fits is 4. Take it once, leaving 2.403112coin

Greedy Choice: Coins where greedy fails

Decision, step 2 of 4

6 left. 4 fits, so take it once: 6 - 4 = 2.

How greedy choice works

Cost

Space
O(1)

Before this

Leads to

Topics that need this one first.

Taught by the same lesson

Greedy Choice covers these too, in the same run.