subject
Engineering, 25.02.2020 22:07 amariciara05

A greedy algorithm for making change is the cashier's algorithm, which all young wizards learn. Malfoy writes the following pseudocode on the whiteboard to illustrate it, where n is the amount of money to make change for and ? is a vector of the coin denominations: wizardChange(n, v): d[1 .. v. len()] =0//initial histogram of coin types in solution while n > 0 {k = r while (v[k] > n and k >= 0) {k--} if k==0 {return 'no solution'} else {d[k]++}} return d Hermione snorts and says Malfoy's code has bugs. Identify the bugs and explain why each would cause the algorithm to fail. (b) Sometimes the goblins at Gringotts Wizarding Bank run out of coins, and make change using whatever is left on hand. Identify a set of U. S. coin denominations for which the greedy algorithm does not yield an optimal solution. Justify your answer in terms of optimal substructure and the greedy-choice property. (The set should include a penny so that there is a solution for every value of n.)

ansver
Answers: 3

Another question on Engineering

question
Engineering, 04.07.2019 18:20
Amixture of slurry and mud is to be pumped through a horizontal pipe of diameter 500 mm. the fluid behaves as a bingham plastic with a yield stress of 30 pa and viscosity 0.04 pa.s. describe the effects of the shear stress through a transverse section of the pipe by plotting the variation in shear stress and velocity profile: (i) just before the slurry starts to move (ii) as the slurry flows when the pressure gradient is double that in part (i)
Answers: 3
question
Engineering, 04.07.2019 19:10
Plan an experiment to measure the surface tension of a liquid similar to water. if necessary, review the ncfmf video surface tension for ideas. which method would be most suitable for use in an undergraduate laboratory? what experimental precision could be expected?
Answers: 2
question
Engineering, 06.07.2019 04:10
Cold water (cp=4180j/kg k) leadıng to a shower enters a thin-walled double-pipe heat transfer at 15c at a rate of 0.25kg/s and is heated to 45c by hot water (cp=4190j/kg k) that enters at 100c at the rate of 3kg/s. if the overall heat transfer coefficient is 950w /m2 k , determıne the rate of heat transfer and the heat transfer surface area of the heat exchanger using e - ntu method
Answers: 1
question
Engineering, 06.07.2019 04:30
Mention three advantages and two disadvantages of cmm.
Answers: 1
You know the right answer?
A greedy algorithm for making change is the cashier's algorithm, which all young wizards learn. Malf...
Questions
question
English, 10.08.2021 19:50
question
Mathematics, 10.08.2021 19:50
question
Mathematics, 10.08.2021 19:50
Questions on the website: 13722360