Coin change needs a table
transcript
A shop has coins worth one, three and four. It must give change of six. Use as few coins as possible. Which coins should it give? Greedy and a table disagree.
Biggest coin first takes a four. Two is left, so it gives a one and a one. Greedy never takes a coin back. That is three coins. But three and three is two coins. Greedy was wrong here, and nothing about these coins makes it safe.
Make a table with one cell for each amount. Each cell holds the fewest coins for that amount. Amount six tries every coin. Leaving five gives three coins. Leaving three gives two. Leaving two gives three. Keep the smallest: two coins.
The table tries every coin. It keeps the smallest count. So no counterexample can fool it. There is nothing to prove about a rule.
When greedy has no proof, use a table. Each cell reads cells to its left. Full breakdown in the lecture.