Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please show all work 2. Coin Changing Problem Suppose you are given an unlimited supply of coins in each of the n denominations d =
please show all work
2. Coin Changing Problem Suppose you are given an unlimited supply of coins in each of the n denominations d = (di, d2...., dn), and a number N of monetary units to be paid out using the least possible number of coins. a. Show that this problem exhibits optimal substructure, i.e. show how to divide the problem into subinstances of the same problem in such a way that every subinstance solution is a combination of other subinstance solutions. b. Write a recurrence relation for the value of an optimal solution. Include boundary and out of bounds values. c. Write a dynamic programming algorithm that fills in a table of values defined by the recurrence relation you wrote in (b). Your algorithm should take as input the vector d and the number N, and return the value of an optimal solution, i.e. the least number of coins necessary to pay N units, or returns oo if it is not possible to disburse N units using denominations d. d. Write a recursive procedure that, given the table of sub-instance solutions generated by the algorithm in (c), prints out a list of coins to be disbursed, i.e. print the optimum solution itself. 2. Coin Changing Problem Suppose you are given an unlimited supply of coins in each of the n denominations d = (di, d2...., dn), and a number N of monetary units to be paid out using the least possible number of coins. a. Show that this problem exhibits optimal substructure, i.e. show how to divide the problem into subinstances of the same problem in such a way that every subinstance solution is a combination of other subinstance solutions. b. Write a recurrence relation for the value of an optimal solution. Include boundary and out of bounds values. c. Write a dynamic programming algorithm that fills in a table of values defined by the recurrence relation you wrote in (b). Your algorithm should take as input the vector d and the number N, and return the value of an optimal solution, i.e. the least number of coins necessary to pay N units, or returns oo if it is not possible to disburse N units using denominations d. d. Write a recursive procedure that, given the table of sub-instance solutions generated by the algorithm in (c), prints out a list of coins to be disbursed, i.e. print the optimum solution itself Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started