Question: Problem 5 : PART - A: Consider the following change - making problem: The input to this problem is an integer L . The output
Problem :
PARTA:
Consider the following changemaking problem: The input to this problem is an integer LThe output should be the minimum cardinality collection of coins required to make L shillings of change, that is you want to use as few coins as possible. The coins are worth and shillings. Assume that you have an unlimited number of coins of each type. Formally prove or disprove that the greedy algorithm that takes as many coins as possible from the highest denominations correctly solves the problem. So for example, to make a change for Shillings, the greedy algorithm would require ten coins: four shilling coins, one shilling coin, one shilling coin, and four shilling coins.
PARTB :
Consider another changemaking problem: The input to this problem is again an integer L and the output should again be the minimum cardinality collection of coins required to make L nibbles of change that is you want to use as few coins as possible Now the coins are worth nibbles. Assume that you have an unlimited number of coins of each type. Prove or disprove that the greedy algorithm that takes as many coins of the highest value as possible solves the changemaking problem.
Hint: The greedy algorithm is correct for one of the above two subproblems and is incorrect for the other. For the problem where greedy is correct, use the following proof strategy: Assume, to reach a contradiction, that there is an input I on which greedy is not correct. Let OPTI be a solution for input I that is better than the greedy output GI Show that the existence of such an optimal solution OPTI that is different than greedy is a contradiction. So what you can conclude from this is that for every input, the output of the greedy algorithm is the unique optimalcorrect solution.
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
