Consider the problem of making change for n cents using the


Consider the problem of making change for n cents using the fewest number of coins. Assume that each coin's value is an integer.

Describe a greedy algorithm to make change consisting of quarters (25 cents each), dimes (10 cents each), nickels (5 cents each), and pennies (1 cent each). Prove that your algorithm yields an optimal solution.

Give a set of coin value combination (the value of coins may not be limited to quarter, dime, nickel, or penny) for which the greedy algorithm does not yield an optimal solution. Your set should include a penny value so that there is a solution for every possible value of n. Use an example to justify your answer.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Consider the problem of making change for n cents using the
Reference No:- TGS01541388

Now Priced at $20 (50% Discount)

Recommended (96%)

Rated (4.8/5)