Programming Algorithm Prob
QUESTION: Change DPChange to return not only the smallest number of coins, but to also return the correct combination of coins.
DPChange (M, c, d)
1 bestNumCoins_0 <-- 0
2 for m <-- 1 to M
3 *indent*bestNumCoins_m <-- infinity
4 *indent*for i <-- 1 to d
5 *indent**indent*if m >= c_i
6 *indent**indent**indent*if bestNumCoins_(m-c_i) + 1 < bestNumCoins_m
7 *indent**indent**indent**indent*bestNumCoins_M <-- bestNumCoins_(m-c_i) + 1
8 return bestNumCoins_M
NOTE: for line 7, shouldn't be going on a diff line but couldnt fit all in 1...
*EDIT* Nevermind on note, looks like it all fit.
Thanks for any help. I hate programming and it shouldn't be part of math !