A new coin that is worth exactly 4 cents has been add to our currency system. Prove or disprove the statement: "The cashier`s algorithm using quarters, dimes, nickels, 4 cent coins, and pennies and will always produce change using the fewest coins possible

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 19PE
icon
Related questions
Question
100%

A new coin that is worth exactly 4 cents has been add to our currency system. Prove or disprove the statement: "The cashier`s algorithm using quarters, dimes, nickels, 4 cent coins, and
pennies and will always produce change using the fewest coins possible."

Expert Solution
Step 1

Allow us first to demonstrate unequivocally that the coin - changing issue has ideal foundation.

Assume we have an ideal answer for an issue of making change for n pennies, and we realize that this ideal arrangement utilizes a coin whose worth is c pennies; let this ideal arrangement utilize k coins. We guarantee that this ideal answer for the issue of n pennies should hold inside it an ideal answer for the issue of n - c pennies. We utilize the standard reorder contention. Obviously there are k - 1 coins in the answer for the n - c pennies issue utilized inside our ideal answer for the n pennies issue. Assuming we had an answer for the n - c pennies issue that utilized less than k - 1coins, then, at that point, we could utilize this answer for produce an answer for the n pennies issue that utilizes less than k coins, which goes against the optimality of our answer.

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 7 images

Blurred answer
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning