Answered step by step
Verified Expert Solution
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
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
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