Design a dynamic programming algorithm for the Coin-change problem described below: Input: An amount of money C and a set of n possible coin values with an unlimited supply of each kind of coin. Output: The smallest number of coins that add up to C exactly, or output that no such set exists. The algorithm must take O(n C) time. You must also write and explain the recurrence. Example 1: Input: C24, Coin values = = [1, 5, 10, 25, 50] Output: 6 (since 24 = 10+ 10+1+1 +1 + 1) Example 2: Input: C = 86, Coin values = [1, 5, 6, 23, 35, 46, 50] Output: 2 (since 86 = 46+35+5)
Design a dynamic programming algorithm for the Coin-change problem described below: Input: An amount of money C and a set of n possible coin values with an unlimited supply of each kind of coin. Output: The smallest number of coins that add up to C exactly, or output that no such set exists. The algorithm must take O(n C) time. You must also write and explain the recurrence. Example 1: Input: C24, Coin values = = [1, 5, 10, 25, 50] Output: 6 (since 24 = 10+ 10+1+1 +1 + 1) Example 2: Input: C = 86, Coin values = [1, 5, 6, 23, 35, 46, 50] Output: 2 (since 86 = 46+35+5)
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 24PE
Related questions
Question
![Design a dynamic programming algorithm for the Coin-change problem described below:
Input: An amount of money C and a set of n possible coin values with an unlimited supply of each
kind of coin.
Output: The smallest number of coins that add up to C exactly, or output that no such set exists.
The algorithm must take O(n C) time. You must also write and explain the recurrence.
Example 1:
Input: C24, Coin values = = [1, 5, 10, 25, 50]
Output: 6 (since 24 = 10+ 10+1+1 +1 + 1)
Example 2:
Input: C = 86, Coin values = [1, 5, 6, 23, 35, 46, 50]
Output: 2 (since 86 = 46+35+5)](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F602caea4-3d4d-49a2-a5cf-03841bb038cc%2Fc464db92-b95c-4c05-ab9a-146411210381%2Fhyggpt_processed.png&w=3840&q=75)
Transcribed Image Text:Design a dynamic programming algorithm for the Coin-change problem described below:
Input: An amount of money C and a set of n possible coin values with an unlimited supply of each
kind of coin.
Output: The smallest number of coins that add up to C exactly, or output that no such set exists.
The algorithm must take O(n C) time. You must also write and explain the recurrence.
Example 1:
Input: C24, Coin values = = [1, 5, 10, 25, 50]
Output: 6 (since 24 = 10+ 10+1+1 +1 + 1)
Example 2:
Input: C = 86, Coin values = [1, 5, 6, 23, 35, 46, 50]
Output: 2 (since 86 = 46+35+5)
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps

Recommended textbooks for you

C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning

C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr

Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning

C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning

C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr

Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning

Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage

EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT