Re: Efficient algorithm?



On Mar 18, 9:12 pm, "Ez_Alg" <virtualreal...@xxxxxxxxx> wrote:
Given an unlimited supply of coins of denominations x1; x2; : : : ;
xn, we wish to make change for a value v using at most k coins; that
is, we wish to find a set of k coins whose total value is v.
This might not be possible: for instance, if the denominations are 5
and 10 and k = 6, then we can make change for 55 but not for 65. what
is an efficient dynamic-programming algorithm for the following
problem.
Input: x1; : : : ; xn; k; v.
Question: Is it possible to make change for v using at most k coins,
of denominations x1; : : : ; xn?
any help would be appriciated.

Dynamic programming means remember results on (structured) subsets of
the input. Often (as is probably best in this case) you'll remember it
in a table. What do you think your table should look like?

Now... how do you fill out that table? Consider denomination 'xn'.
There's a solution for v using a single coin of size xn if...what?
(that's gives you your recursive function to help compute the table).

Mitch

.



Relevant Pages

  • Re: Self Check-Out machines that take $2 Bills and Halves? Attn: Fred Shecter
    ... Ike dollaes are "uncurrent" as they were superseded by the SBA in 1979. ... All self check machinces accept and dispense the annoying one cent coins. ... Halves and $2 bills are current denominations. ...
    (rec.collecting.coins)
  • Re: USA Today says dump the penny
    ... I would hope that whatever the object of the euro ... gave the governments data on who had the money? ... it comes to keeping the low value coins. ... one of the available denominations. ...
    (rec.collecting.coins)
  • Re: Cashbox withdrawal
    ... In my case, I have limited amount ... > infitine number of coins for each denomination. ... > together with textbook formulas for Taylor expansion. ... but it sounds similar (albeit with just two denominations). ...
    (sci.math)
  • Re: The big bad stamp is returning
    ... the ratio between successive denominations should be either 5 or 4, ... and 25-cent coins was sporadic. ... silver and nickel three-cent pieces, ... quality counterfits become feasible? ...
    (rec.arts.sf.fandom)
  • Re: Coin exchange with finite number denominations
    ... >much related to the subset sum problem. ... >whether his cashbox contains any collection of coins and notes that sum ... if the number of denominations is limited and there are many copies ... together with textbook formulas for Taylor expansion. ...
    (comp.theory)