Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1 (Coin changing problem) Suppose that you want to carry a money amount of n cents and you want to minimize the number of

image text in transcribed

Question 1 (Coin changing problem) Suppose that you want to carry a money amount of n cents and you want to minimize the number of coins to carry. We only consider pennies, nickels, dimes, and quarters with denominations 1, 5, 10, and 25 cents, respectively. For example, an amount of n = 71 cents becomes two quarters, two dimes and a penny. An amount of n=81 becomes three quarters, a nickel, and a penny. 1. Describe a greedy algorithm to solve the above problem and write a pseudo code for it. 2. Prove the optimality of your greedy algorithm. Hint: You can consider each of the four possible decisions separately, i.e., picking a penny, a nickel, a dime, and a quarter, preferably in this order. 3. Establish the running time of your algorithm. 4. Apply your algorithm to the problem when n = 57

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

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions

Question

3. What is a Duchenne smile?

Answered: 1 week ago

Question

Understand the different approaches to job design. page 167

Answered: 1 week ago