Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A complete answer consists of three parts: a description of the algorithm, a proof of correctness, and a running time analysis No complicated code: English

image text in transcribed

A complete answer consists of three parts: a description of the algorithm, a proof of correctness, and a running time analysis No complicated code: English is the best way to express an algorithm combined with some simple pseudocode when needed. You are not writing a computer program so avoid unnecessary details in your algorithms. 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). 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

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 Processing Fundamentals Design And Implementation

Authors: David M. Kroenke

5th Edition

B000CSIH5A, 978-0023668814

More Books

Students also viewed these Databases questions

Question

Define turnover and turnover intent.

Answered: 1 week ago