Optimality of Greedy Change-Making

​
number of coins
3
4
5
6
7
coin 2 - coin 1
1
coin 3 - coin 2
4
coin 4 - coin 3
6
coin 5 - coin 4
12
coin 6 - coin 5
24
coin 7 - coin 6
12
Coin set: 1, 2, 6, 12, 24, 48, 60
The minimal example showing greedy failure is 96.
The greedy representation of 96 is {0,0,0,1,1,0,1}.
The minimal representation of 96 is {0,0,0,0,0,2,0}.
The U.S. coin set of 1, 5, 10, 25, 50, 100 satisfies the greedy condition, meaning that if you make change for an amount
A
greedily (always choosing the largest coin that fits in the amount left) you get a representation of A that uses the fewest possible coins. The old British system based on the halfpenny as the unit corresponds to coins 1, 2, 6, 12, 24, 48, 60, and that system is not greedy: 96 = 48 + 48 but the greedy method gets 96 = 60 + 24 + 12. An efficient algorithm due to Pearson determines whether a set satisfies the greedy condition or not, and if not, finds the smallest target amount that demonstrates the failure. The sliders in the Demonstration control the coin differences, so to see the U.S. system, set
n
to 6 and the differences to 4, 5, 15, 25, 50.

Details

For more details on Pearson's algorithm see
D. Pearson, "A Polynomial-Time Algorithm for the Change-Making Problem," Operations Research Letters, 33(3), 2005 pp. 231–234.

Permanent Citation

Stan Wagon
​
​"Optimality of Greedy Change-Making"​
​http://demonstrations.wolfram.com/OptimalityOfGreedyChangeMaking/​
​Wolfram Demonstrations Project​
​Published: March 7, 2011