Question: 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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!