Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Describe a dynamic programming algorithm to solve the problem of giving change optimally for all A. Analyze its runtime. Problem 5. Define the problem of

image text in transcribed

Describe a dynamic programming algorithm to solve the problem of giving change optimally for all A. Analyze its runtime.

Problem 5. Define the problem of giving change as follows: Given a sorted array A of n distinct, positive integers with A 11-1 and a positive integer u, return an array B of length n such that -1 A[ * Bli-u and ,1B[n] is minimized. A represents the different coins, u is the amount of money needing to be returned, B tells us how many of each kind of coin to use, and the restrictions on B ensure that the correct amount is returned and the number of coins used is minimized. For U.S. currency, for instance, A = [1, 5, 10, 25, 50, 100]. Then for u = 289, B = 4,0, 1,1, 1,2]. Note that AII] = 1 is included to ensure that there is always a solution Describe a greedy algorithm to solve this problem. Analyze its runtime. The greedy approach does not guarantee an optimal solution for all A. Give an example where the greedy algorithm would return a solution that uses at least 5 more coins than necessary

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 And Expert Systems Applications 31st International Conference Dexa 2020 Bratislava Slovakia September 14 17 2020 Proceedings Part 1 Lncs 12391

Authors: Sven Hartmann ,Josef Kung ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

303059002X, 978-3030590024

More Books

Students also viewed these Databases questions