Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

A country has coins with k denominations 1 = d1 < d2 < ... < dk, and you want to make change for n cents using the smallest number of coins.

For example, in the United States we have d1 = 1, d2 = 5, d3 = 10, d4 = 25, and the change for 37 cents with the smallest number of coins is 1 quarter, 1 dime, and 2 pennies, which are a total of 4 coins.

To solve for the general case (change for n cents with k denominations d1 ... dk), we refer to dynamic programming to design an algorithm.

1. We will come up with sub-problems and recursive relationship for you. Let be the minimum number of coins needed to make change for n cents, then we have:

 

Explain why the above recursive relationship is correct. [Formal proof is not required]

 

2. Use the relationship above to design a dynamic programming algorithm, where the inputs include the k denominations d1 ... dk and the number of cents n to make changes for, and the output is the minimum number of coins needed to make change for n.

Provide the pseudocode of your algorithm and briefly justify the runtime of your algorithm using big-O notation.

 

3.  Adapt your algorithm above by tracking some useful information during the DP procedure, so that it returns the actual method (i.e., the number of coins for each denomination) to change for n cents, not just the minimum number of denominations.

C[n] =
(minimum{C[n
disn
0,
− d¡] + 1}, if n>0
if n = 0
expand button
Transcribed Image Text:C[n] = (minimum{C[n disn 0, − d¡] + 1}, if n>0 if n = 0
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
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
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education