Short description: Given portions of a DP solution, complete the algorithm; justify correctness.
Relevant notes: Topic F: Dynamic Programming.
Given a dynamic programming problem and parts of the algorithm, fill in the missing parts. Justify correctness. The missing parts may be parts of the recurrence or computing the final solution.
Consider the problem of knapsack with no duplicates:
Consider this dynamic programming partial solution:
Part a. What mandatory component is missing? Fill it in and prove correctness.
Part b. What optional component is missing? Briefly explain how to obtain that component.
Part a.
The recurrence, inductive case: C[i,x] = max(C[i-1,x], v[i] + C[i-1, x-w[i]]) where the second case is only considered if w[i] <= x.
Proof: to fill a knapsack of weight limit x with items 1,...,i, the optimal solution either has item i or doesn't. If it doesn't, then it has a subset of items 1,...,i-1, so its value is equal to C[i-1,x]. If it does, then the remaining space is x - w[i] and it must be used optimally, so its value is C[x - w[i]], so the total value is v[i] + C[i-1, x-w[i]].
We take the maximum over these two possibilities, so C[i,x] is the optimal solution.
Part b. Reconstructing the solution.
We can create an array D[i,x] = False if C[i,x] == C[i-1,x], and otherwise D[i,x] = True, meaning that C[i,x] == v[i] + C[i-1,w-w[i]] and we used item i at this stage.
We then start with D[n,W].
If False, we go to D[n-1, W].
If True, we add item n to the knapsack and go to D[n-1, W - w[n]].
We continue in this way until we get to D[0,x] for any x.
To pass, a solution must follow the course requirements for writing and proofs.
To pass Part a, the solution must identify that the recurrence inductive case is needed, give the correct recurrence, and give a correct justification. The justification can be brief, but must still give a correct, useful justification.
To pass Part b, the solution must identify reconstructing the solution. It should give a correct, clearly understandable method for reconstruction.
The numerical rubric for this problem is: