I was seeing the Coin Change problem. In general, the input is n (the change to be returned) and the denominations (values of coins in cents) available, v1 < v2 < v1 < ... < vk; the goal is to make the change for n cents with the minimum number of coins.
I was reading this pdf from Columbia university, but I don't get why, at slide number 6, we have a +1 in the recurrence relation:
Does it represent the coins we've already used?
x
, found in one step of the algorithm. - WelbogC[p] = 1+C[p-x]
it means that the number of coins to obtain a valuep
is one plus the number of coins to generateC[p-x]
if we add a coinx
, so the+1
simply is used to "increment" the number of coins. - Willem Van Onsem