Question: 1. Consider the problem of returning change to a customer requiring the smallest number of coins. a. Show that the greedy algorithm given below

  1. 1. Consider the problem of returning change to a customer requiring the 

1. Consider the problem of returning change to a customer requiring the smallest number of coins. a. Show that the greedy algorithm given below returns the smallest number of coins for the coin set {1,5, 10, 25}. Procedure Greedy (C: change amount) Arrays c and a are global variables. c[i] amount of coin type i (c[i]> c[i+1]) x[i] solution number of coins of type i in solution (initially x[i] = 0) begin if C 0 then return else begin i = 1; while c[i]>C doi = i + 1; x[i] = x[i] + 1; C=C c[i]; Greedy(C); end; end. b. Does the algorithm compute the correct answer for all coin types?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

It appears that youve provided an image of a computer science homework question regarding a greedy algorithm for making change with a specific coin se... View full answer

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 Computer Network Questions!