Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learn Mysql The Easy Way A Beginner Friendly Guide

Authors: Kiet Huynh

1st Edition

B0CNY7143T, 979-8869761545

More Books

Students also viewed these Databases questions