CSci 280: Algorithms and problem-solving paradigms
Home Syllabus Classwork

printable version

Quiz 2 Review

Section F11: [1]
Section F16: [1]
Section F18: [1] [2] [3]
Section F20: [1]
Section F23: [1] [2] [3]
Section F25: [1] [2]
Section F27: [1]

Problem F11.1.

In the knapsack problem, we imagine we're given some capacity c and a list of n weights w0, w1, … wn − 1. We saw in class that we can solve it using dynamic programming in O(c ⋅ n) time based on the following recurrence.

Suppose our knapsack also has a limit that restricts it from holding more than k items? How can we modify our recurrence to lead to a dynamic programming solution that takes O(c ⋅ n ⋅ k) time?