Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(b) (8 pts) Sometimes the goblins at Gringotts Wizarding Bank run out of coins,1 and make change using whatever is left on hand. Identify a

image text in transcribed

(b) (8 pts) Sometimes the goblins at Gringotts Wizarding Bank run out of coins,1 and make change using whatever is left on hand. Identify a set of Euro coin denominations (a subset of the denominations here) 2 for which the greedy algorithm does not yield an optimal solution for making change. Justify your answer in terms of optimal substructure and the greedy-choice property. (The set should include the 1 Euro cent so that there is a solution for every value of n.)

3. Draco Malfoy is struggling with the problem of making change for n cents using the smallest number of coins. Malfoy has coin values of vi > v2 > . . > vr for r coins types, where each coin's value vi is a positive integer. His goal is to obtain a set of counts {di}, di-k and where k is minimized one for each coin tvpe, such that (a) (7 pts) A greedy algorithm for making change is the cashier's algorithm, which all young wizards learn. Malfoy writes the following pseudocode on the white- board to 1llustrate it, where n is the amount of money to make change for and v is a vector of the coin denominations: wizardChange (n,v,r) : d[1 .. r] = 1 while n > 0 // initial histogram of coin types in solution while k > 0 and v[k] > n ) ( kt+h if k=-o { return 'no solution, } else n -n - v[k] h return d Hermione scoffs and says Malfoy's code has bugs. Identify the bugs and explain why each would cause the algorithm to fail

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

The Database Relational Model A Retrospective Review And Analysis

Authors: C. J. Date

1st Edition

0201612941, 978-0201612943

More Books

Students also viewed these Databases questions

Question

=+ (f) Show for 0 x 1 that D( A) =x for some A.

Answered: 1 week ago