Answered step by step
Verified Expert Solution
Question
1 Approved Answer
16-1 Coin changing Consider the problem of making change for n cents using the fewest number of coins. Assume that each coin's value is an
16-1 Coin changing Consider the problem of making change for n cents using the fewest number of coins. Assume that each coin's value is an integer a. Describe a greedy algorithm to make change g of quarters, dimes, nickels, and pennies. Prove that your algorithm yields an optimal solution. Problems for Chapter 16 447 b. Suppose that the available coins are in the denominations that are powers of c, i.e., the denominations are c.c1....ck for some integers c> 1 and k Show that the greedy algorithm always yields an optimal solution. c. Give a set of coin denominations for which the greedy algorithm does not yield an optimal solution. Your set should include a penny so that there is a solution or every value of n. d. Give an O(nk)-time algorithm that makes change for any set of k different coin denominations, assuming that one of the coins is a penny
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