I am trying to solve a problem using dynamic programming and the problem goes as follows:
Given an unlimited supply of coins (penny, nickel, dime, double-dime, quarter) with values (1, 5, 10, 20, 25), please find the smallest number of coins to make change for 65 cents. What coins (and how many of each) are used? Illustrate the table(s) required by using the dynamic programming algorithm and how you get what coins are used.
Note I do not expect anyone to illustrate the entire table for me, but I am kind of stuck on how I fill in the table for this problem.
I know my table would look a little like this:
5 10 15 20 25 30 35 40 45 50 55 60 65
1
5
10
20
25
( I am omitting the 1's because I know that is not the best solution) My initial thought is that the table would be filled out a little like this:
5 10 15 20 25 30 35 40 45 50 55 60 65
1
5 1 2 4 5 5 6 7 8 9 10 11 12 13
10 0 1
20
25
I get stuck here when I have to go further. I do not think I am understanding how dynamic programming works for this problem completely. I have been reading my book, and reading online but I am still a bit confused.
EDIT:
Thanks to one of the answers this is how I worked out the solution:
5 10 15 20 25 30 35 40 45 50 55 60 65
1
5 1 1 1 1
10 1 1 1 1
20 1 2 1 2
25 1 1 1 1 2 2 2 1