Greedy Algorithms8 sections · 316 units
Open in Course

Example - Coin Change (Greedy Works)

Standard denominations

Make change for 6767 cents using US coins (2525, 1010, 55, 11). Minimize the number of coins. Greedy approach: always pick the largest coin that fits. 1.1. 6767 cents: take 2525 (4242 left)

2.2. 4242 cents: take 2525 (1717 left)

3.3. 1717 cents: take 1010 (77 left)

4.4. 77 cents: take 55 (22 left)

5.5. 22 cents: take 11, take 11 (00 left) Total: 66 coins. That's optimal for US coins. Why does greedy work here? Because US coins form a canonical system: each coin divides evenly into larger ones. This structure guarantees greedy works.