Question: Consider the Change - Making problem. Given a target change of K = 8 and a set of n = 4 coin denominations with the
Consider the ChangeMaking problem. Given a target change of K and a set of n coin denominations with the following values val we want to compute the minimum number of coins needed to make the exact amount of change.
Q: Consider a greedy approach to solving the problem. The approach is to add coins in decreasing order of value. How many coins would this greedy approach produce for the K change and the four coin denominations described above?
Q: The pseudocode below is a dynamic programming solution to the problem.
int CM new intKtable for subproblem solutions
CM coins for change
for int c ; c K; csolve subproblems bottom up
int min Integer.MAXVALUE;
for i ; i n; ifor all coin denominations
if vali c && CMc vali min
min CMc vali;
CMc min;
Q: What is the value of CM
Q: What is the value of CM
Q: What is the value of CM
Q: What is the minimum number of coins to make the exact change amount of K
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
