You are here:

Number Theory/Coin exchange problem

Advertisement


Question
QUESTION: Hi,
Recently,I read some articles regarding the coin exchange problem and its solution. All the solutions using dynamic programing assume that one coin has value 1(in order to guarantee that there is a solution).
My question is this: Can I use the same algorithm without the assumption (coin value 1)that will inform me if there isn't a solution to the problem (if that turns out to be the case)?
In other words, given a natural number N, and M different coin denominations (but not necessarily coin with the value 1), all I wont to know is: can this number (N) be represented as a linear combination of these coins.
Hope I have been clear enough.
Regards,
Samir

ANSWER: To be sure and get every value, a coin with a value 1 is needed.
In the US, a note of currency is worth 100 cents.

Now if you had a coin worth 2 and a coin worth 3, every number in the list could be found to be a sum of N 2 cent and M 3 cent coins, but what if something was only 1 cent? I couldn't be done unless you gave them 3 cents and they returned 2 cents, but giving change is not allowed in this problem.


---------- FOLLOW-UP ----------

QUESTION: I get your point completely, but I'm afraid I failed to explain what was mine.
So, let me try this way: Can I use the same dynamic programing algorithm (used for solving the coin exchange problem) to answer a Yes/No question to wether a certain number N can be expressed as a linear combination of some subset of M coins (all with different denominations but none with a value 1).
Sorry for troubling you again,
Samir

Answer
As far as dynamic programming is concerned, the answer is yes.
I believe it would take the large coin and get as many as it could.
It would then take the next largest coin and add them on.

I believe that the change machines in most stores use this approach when dispensing change.
The only thing to check for is if the macine is out of any of the coins.
The simple ones are 1 dime is 2 nickecls, 1 dime is 10 pennies, 1 nickel is 5 pennies.
Quarters get a bit tricky, for 30 cents is either 1 quareter and 1 nickel, or 3 dimes.

I'm sure that they have been programmed to give as few coins as possible,
yet sometimes I wonder if they have been instructed to gives3 dimes
if they have a lot of dimes for 30 cents as opposed to a quarter and a nickel.

Since the coin machines do it, it must have been humanly solved and programmed.

Number Theory

All Answers


Answers by Expert:


Ask Experts

Volunteer


Scott A Wilson

Expertise

I can answer almost anything that is sent in. If I can't, I'll let you know, but I don't expect that to happen much.

Experience

I have known about it since the mid 80's. There were a few questions in Number Theory in this software. I have answered several thousand other questions in mathematics.

Publications
You're looking at it ... I've answered over 7000 quesitons in mathematics right here.

Education/Credentials
My credentials are an MS in Mathematics at Oregon State and a BS in Mathematics at the same place.

Awards and Honors
I graduated with honors in Mathematics when gettin my BS and MS.

Past/Present Clients
People at OSU and maybe you're friend in math on some other computer, late last night, with thousands of miles between us ...

©2012 About.com, a part of The New York Times Company. All rights reserved.