Professional Documents
Culture Documents
DP Trick or Treat
DP Trick or Treat
iS
ni m
and
iS
ti is minimized.
For the questions below, your analysis should be given in terms of the number of houses n and the sum of the waiting times: T =
n i=1
ti .
1. (8 points) Show that the greedy strategy that collects candy based on the ratio ni /ti (largest to smallest) does not result in the optimum solution. (Give a counterexample.) 2. (15 points) Describe a dynamic programming algorithm for this problem. Be sure to describe the choices and subproblems involved in English. Do not use pseudo-code. 3. (5 points) Describe how the minimum total waiting time for a problem relates to the minimum total waiting time for its subproblems. 4. (5 points) Analyze and justify the running time of your dynamic programming algorithm.