Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider the problem of using the fewest number of coins to make change for an amount of money. Let C1>C2>>Cn=1 be n1 coins of distinct
Consider the problem of using the fewest number of coins to make change for an amount of money. Let C1>C2>>Cn=1 be n1 coins of distinct integer denominations. (For example, C1=10,C2=5, and C3=1, etc.) Given a certain integer amount S, we would like to use the fewest number of coins to the amount S. For example, if S=18, then given the above 3 types of coins, we need 5 coins (one C1, one C2, and 3C3 ). The answer of the problem is thus 5 for this example. One possible solution of the problem is to solve it recursively. Let N[i][j] be the least number of coins needed to obtain the amount j using coins Ci through Cn (i.e., only coins of types Ci,,Cn are used; coins of types C1,,Ci1 are not used). (a) (i) What is the fewest number of coins needed given C1=10,C2=6,C3=1,S=18 ? (ii) What is N[2][17] given C1=10,C2=6,C3=1 ? (b) Argue that the following recurrence equation is correct: N[i][j]={N[i+1][j],min{N[i+1][j],N[i][jCi]+1},ifCi>j,ifCij. (c) What are the base cases for the above recursive strategy
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