Optimality of Greedy Change-Making

Initializing live version
Download to Desktop

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



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.

Feedback (field required)
Email (field required) Name
Occupation Organization
Note: Your message & contact information may be shared with the author of any specific Demonstration for which you give feedback.