Professional Documents
Culture Documents
DP Coin Change Fall 17
DP Coin Change Fall 17
Dynamic Programming
Problem: Find minimum number of
coins that make a given value
• Make a change, Total = 13
• Available Coin Set = { 6, 2, 7, 3 }
T[i] [j] is the 2D array to denote the minimum number of coins require to make the change
Coin[i] is the sorted array of available coin sets. [Index Start from 1]
0 1 2 3 4 5 6 7 8 9 10 11 12 13
7
0 1 2 3 4
Coin[ i ] = 2 3 6 7
0 1 2 3 4 5 6 7 8 9 10 11 12 13
0 ∞ ∞ ∞ ∞ ∞ ∞ ∞ ∞ ∞ ∞ ∞ ∞ ∞
2 0 ∞ 1 ∞ 2 ∞ 3 ∞ 4 ∞ 5 ∞ 6 ∞
3 0 ∞ 1 1 2 2 2 3 3 3 4 4 4 5
6 0 ∞ 1 1 2 2 1 3 2 2 3 3 2 4
7 0 ∞ 1 1 2 2 1 1 2 2 2 3 2 2
Result: