Question: Consider the problem of making change for n cents using the fewest number of coins. Assume that each coins value is an integer. a. Describe
Consider the problem of making change for n cents using the fewest number of coins. Assume that each coins value is an integer.
a. Describe a greedy algorithm to make change consisting of quarters, dimes, nickels, and pennies. Prove that your algorithm yields an optimal solution.
b. Suppose that the available coins are in the denominations that are powers of c, i.e., the denominations are c0;c1;:::;ck for some integers c > 1 and k 1. 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 for every value of n.
d. GiveanO.nk/-timealgorithmthatmakeschangeforanysetofkdifferentcoin denominations, assuming that one of the coins is a penny.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
