Question: In class, we showed that the cashier's algorithm ( repeatedly taking the largest coin possible ) is not optimal for the currency 1 , 5

In class, we showed that the cashier's algorithm (repeatedly taking the largest coin possible) is not optimal for the currency 1,5,7. Unfortunately, we have to solve this problem using dynamic programming.
(a) Let C(n) be the integer-valued function that describes the fewest number of coins needed to make change for n cents, using the currency 1,5,7, for n0. Describe a mathematical recurrence for C(n).
(b) Use your recurrence to devise a dynamic programming algorithm in pseudocode for computing this function. Your algorithm should be iterative and of the form:
CoINDP(n) :
,?? your code here
What's the runtime of your algorithm?
In class, we showed that the cashier's algorithm

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 Programming Questions!