Engineering
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.)

answer
Answers: 3

Other questions on the subject: Engineering

image
Engineering, 03.07.2019 15:10, brooklyn674
Apiston-cylinder with a volume of 0.25 m3 holds 1 kg of air (r 0.287 k/kgk) at a temperature of 100 c. heat transfer to the cylinder causes an isothermal expansion of the piston until the volume triples. how much heat is added to the piston-cylinder?
Answers: 3
image
Engineering, 04.07.2019 18:20, miguel454545
Along 8-cm diameter steam pipe whose external surface temperature is 900c connects two buildings. the pipe is exposed to ambient air at 70c with a wind speed of 50 km/hr blowing across the pipe. determine the heat loss from the pipe per unit length. (b) air at 500c enters a section of a rectangular duct (15 cm x 20 cm) at an average velocity of 7 m/s. if the walls of the duct are maintained at 100c. a) the length of the tube for an exit temperature of the air to be 40 0c. b)the rate of heat transfer from the air. c) the fan power needed to overcome the pressure drop in this section of the duct.
Answers: 1
image
Engineering, 04.07.2019 19:20, rosemary909
In the winter, in order to keep the classroom steadily at 68 f before 10 pm, heating with an average rate of 42,000 btu/hr is provided. assume the outdoor temperature maintains at 32°f, determine the electrical power (kw) required to (a) operate a reversible heat pump (b) operate a real heat pump with a cop (7) of 4.5 and (c) operate an electrical-resistance heater.
Answers: 3
image
Engineering, 04.07.2019 19:20, amandaaarmentaa
Acircular pipe of 30mm outside diameter is placed in an airstream at 30 c and latm pressure. the air moves in cross flow over the pipe at 20 m/s, while the outer surface of the pipe is maintained at 110 c. what is the drag force exerted on the pipe per unit length? what is the rate of heat transfer from the pipe per unit length?
Answers: 1
Do you know the correct answer?
A greedy algorithm for making change is the cashier's algorithm, which all young wizards learn. Malf...

Questions in other subjects: