191 views
0 votes
0 votes

Suppose an array A={a1,a2,…………an} contains a set of n distinct coins types where each ai € N for 1<=n. Suppose also that a1<a2<a3……………<an the coin hanging problem is defined as follows:

Given W € N , find the smallest numbers of coins from A  that adds upto W, given an unlimited number of coins of each type are available. We wish to find minimum number of coins needed from A to get W as c(n,W). Let  c(i,j) be the minimum number of coins needed from any subset of first “i” coin that sum to exactly “j”.

An incomplete recursive definition for the function c(i,j) is given below

C(i,j)=0                                           if j=0

       =∞                                          if i=0 and j≠0

      =expr1                                    if i,j>0 and j<a[i]

     =expr2                                    if  i,j>0 and a[i]<=j

Please log in or register to answer this question.

Related questions

0 votes
0 votes
1 answer
2