Optimality of Greedy Change-Making
Requires a Wolfram Notebook System
Interact on desktop, mobile and cloud with the free Wolfram Player or other Wolfram Language products.
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 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 to 6 and the differences to 4, 5, 15, 25, 50.
Contributed by: Stan Wagon (Macalester College) (March 2011)
Open content licensed under CC BY-NC-SA
Snapshots
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
"Optimality of Greedy Change-Making"
http://demonstrations.wolfram.com/OptimalityOfGreedyChangeMaking/
Wolfram Demonstrations Project
Published: March 7 2011