Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Suppose the coinage includes the values given in Section 6.1, but you have run out of nickels. Show that using the greedy algorithm with the
Suppose the coinage includes the values given in Section 6.1, but you have run out of nickels. Show that using the greedy algorithm with the remaining values does not necessarily produce an optimal solution. Section 6.1 function {make-change} (n): set of coins {Makes change for n units using the least possible number of coins. The constant C specifies the coinage} const C = {100, 25, 10, 5, 1} S leftarrow empty set{S is a set that will hold the solution} s leftarrow 0 {s is the sum of the items in S} while s not equal to n do x leftarrow the largest item in C such that s + x
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