Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 4. We want to purchase an item of price n and for that we have an unlimited (!) supply of three types of coins

image text in transcribed

Problem 4. We want to purchase an item of price n and for that we have an unlimited (!) supply of three types of coins with values 5, 9, and 13, respectively. Our goal is to purchase this item using the smallest possible number of coins or outputting that this is simply not possible. Design a dynamic programming algorithm for this problem with worst-case runtime of O(n). (25 points) Example. A couple of examples for this problem: Given n = 17, the answer is not possible (try it!). Given n = 18, the answer is 2 coins: we pick 2 coins of value 9 (or 1 coin of value 5 and 1 of value 13). Given n = 19, the answer is 3 coins: we pick 1 coin of value 9 and 2 coins of value 5. Given n = 20, the answer is 4 coins: we pick 4 coins of value 5. Given n = 21, the answer is not possible (try it!). Given n = 22, the answer is 2 coins: we pick 1 coin of value 13 and 1 coin of value 9. Given n = 23, the answer is 3 coins: we pick 1 coin of value 13 and 2 coins of value 5.

Problem 4. We want to purchase an item of price n and for that we have an unlimited (!) supply of three types of coins with values 5, 9, and 13, respectively. Our goal is to purchase this item using the smallest possible number of coins or outputting that this is simply not possible. Design a dynamic programming algorithm for this problem with worst-case runtime of O(n). (25 points) Example. A couple of examples for this problem: Given n = 17, the answer is not possible (try it!). Given n= 18, the answer is 2 coins: we pick 2 coins of value 9 (or 1 coin of value 5 and 1 of value 13). Given n= 19, the answer is 3 coins: we pick 1 coin of value 9 and 2 coins of value 5. Given n = 20, the answer is 4 coins: we pick 4 coins of value 5. Given n = 21, the answer is "not possible" (try it!). Given n = 22, the answer is 2 coins: we pick 1 coin of value 13 and 1 coin of value 9. Given n = 23, the answer is 3 coins: we pick 1 coin of value 13 and 2 coins of value 5. Challenge Yourself. Suppose we have two arrays A[1 : n] and B[1 : m] which are both in the sorted order and are consisting of distinct numbers. Design an algorithm that given an integer 1

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

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions

Question

Responsibility reports are used for

Answered: 1 week ago

Question

What Is acidity?

Answered: 1 week ago

Question

Explain the principles of delegation

Answered: 1 week ago

Question

State the importance of motivation

Answered: 1 week ago

Question

Discuss the various steps involved in the process of planning

Answered: 1 week ago

Question

What are the challenges associated with tunneling in urban areas?

Answered: 1 week ago