I am having problems understanding dynamic programming solutions to solve various problems, in particular problems with changing coins:
"Given the value of N, if we want to make changes for N cents, and we have an endless supply of each of S = {S1, S2, ..., Sm} valuable coins, how many ways we can make a change" The order of the coins does not matter .
For example, for N = 4 and S = {1,2,3} there are four solutions: {1,1,1,1}, {1,1,2}, {2,2}, {1,3 }. Thus, the output should be 4. For N = 10 and S = {2, 5, 3, 6} there are five solutions: {2,2,2,2,2}, {2,2,3,3 }, {2,2,6}, {2,3,5} and {5,5}. Thus, the output should be equal to 5.
There is another variation of this problem when the solution is the minimum number of coins to satisfy the amount.
These problems seem very similar, but the solutions are very different .
The number of possible ways of changing: the optimal substructure for this DP (m, n) = DP (m-1, n) + DP (m, n-Sm) , where DP is the number of solutions for all coins up to the mth coin and the number = n
Minimum number of coins: the optimal substructure for this
DP [i] = Min {DP [i-d1], DP [i-d2], ... DP [i-dn]} + 1 , where i is the total amount and d1. .dn represent each nominal coin.
2- , - 1- ? " DP [i] = DP [i-d1] + DP [i-d2] +... DP [i-dn]" DP [i] - , . , . , , ?
:
http://comproguide.blogspot.com/2013/12/minimum-coin-change-problem.html
http://www.geeksforgeeks.org/dynamic-programming-set-7-coin-change/
. - , , .