Lec37 Dynamic Programming
Lec37 Dynamic Programming
• Sequence of decisions.
• Problem state.
• Principle of optimality.
• Dynamic Programming Recurrence
Equations.
• Solution of recurrence equations.
Sequence Of Decisions
n
maximize pi xi
i=1
n
subject to wi xi <= c
i=1
and xi = 0 or 1 for all i
All profits and weights are positive.
Sequence Of Decisions
f(1,c)
f(2,c) f(2,c-w1)
f(5,c)
f(5,c-w1 –w3 –w4)
Time Complexity
• Let t(n) be the time required when n items are
available.
• t(0) = t(1) = a, where a is a constant.
• When t > 1,
t(n) <= 2t(n-1) + b,
where b is a constant.
• t(n) = O(2n).
f(1,c)
f(2,c) f(2,c-w1)
f(5,c)
f(5,c-w1 –w3 –w4)
Integer Weights Dictionary