Greedy Algorithm & Optimal Coin Change

  • Thread starter Thread starter CRGreathouse
  • Start date Start date
  • Tags Tags
    Algorithm
Click For Summary
The discussion explores the effectiveness of the greedy algorithm for making change with various coin denominations. It highlights that while the greedy approach works optimally for certain sets of coins, such as those in a geometric series, it fails in others, like {5, 4, 1} for a total of 8 cents. The conversation also touches on the conditions under which the greedy algorithm is optimal, suggesting superincreasing sequences may not guarantee optimality. A reference to a paper indicates that determining optimal coin combinations can be solved in polynomial time, although finding the least number of coins remains NP-hard. The participants conclude with a counterexample, demonstrating that not all superincreasing sequences yield optimal solutions with the greedy method.
CRGreathouse
Science Advisor
Homework Helper
Messages
2,832
Reaction score
0
I'm not sure that this is the right place for this post, but I couldn't find a better.

Many years ago I considered the problem of making change with (say) quarters, dimes, nickels, and pennies. I tried to prove to myself that what I now call the greedy algorithm (pick the most valuable coin that doesn't take you over your limit) always made optimal change -- that no solutions with fewer coins existed. At the time I wasn't able to find a proof of the specific case {25, 10, 5, 1} but I could see that the general result failed -- consider {5, 4, 1} to make a total of 8 cents. The greedy algorithm gives (5, 1, 1, 1) but (4, 4) is better.

I was wondering if there's a good characterization of what combination of coin values make the greedy algorithm always optimal. Back then I could see that being in a geometric series was a sufficient, but unnecessary, condition. Briefly reconsidering the problem, it seems that the greedy algorithm should be optimal for superincreasing sequences -- but is this necessary for optimality? Any thoughts, counterexamples, or reading/references?
 
Mathematics news on Phys.org
This is certainly a classical problem. A quick search turns up this:

http://mathforum.org/wagon/spring04/p1009.html

(but I can't seem to follow the link contained in it. I don't think you could get the text easily from there anyways)

which makes it sound like a necessary and sufficient condition won't be simple to write. I know there are some nice, simple, sufficient conditions, but I can't remember the usual one, and I think my only hard reference is at work.


edit: I think this is the paper on it. (You can grab it from the "cached: ... PDF" link in the top-right corner) It doesn't seem terribly clear, but maybe I'm just tired. :smile:
 
Last edited:
Hurkyl said:
edit: I think this is the paper on it. (You can grab it from the "cached: ... PDF" link in the top-right corner) It doesn't seem terribly clear, but maybe I'm just tired. :smile:

Thanks a bunch, that's exactly what I was hoping for I'll read through it and see how much I get. I appreciate it!
 
Well, I read the paper. It shows that it can be decided in polynomial time (O(n^2)) if a certain combination of coin values can always be solved optimally with the greedy algorithm, even though determining the least number of coins needed for a given set of coin values and total x is NP-hard.

Also, I was able to find a counterexample to my 'conjecture' above. Not all superincreasing sequences are solved optimally by the greedy algorithm; consider coins {2001, 1000, 1} and total 3000. I'll see if I can find the least superincreasing counterexample now -- clearly, it has exactly 3 coins.

Edit: I think it's {6, 4, 1} with a total of 8.
 
Last edited:
Here is a little puzzle from the book 100 Geometric Games by Pierre Berloquin. The side of a small square is one meter long and the side of a larger square one and a half meters long. One vertex of the large square is at the center of the small square. The side of the large square cuts two sides of the small square into one- third parts and two-thirds parts. What is the area where the squares overlap?

Similar threads

Replies
2
Views
7K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
3
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
2
Views
2K
Replies
6
Views
3K