Lec4Knapsack

# Storing values of sub solutions construct the optimum

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: do n- 2 times : c = a + b; a = b; b = c return c Compute the values "bottom up” Only store needed values: the previous two Same O(n) time complexity, constant space Dynamic Programming •  Characterize the structure of the problem, ie show how a larger problem can be solved using solutions to sub- problems •  Recursively deﬁne the optimum •  Compute the optimum bottom up, storing values of sub solutions •  Construct the optimum from the stored data Optimal substructure !   Dynamic programming works when a problem has optimal substructure: we can construct the optimum of a larger problem from the optima of a "small set" of smaller problems. !   small: polynomial !   Not all problems h...
View Full Document

## This note was uploaded on 02/12/2014 for the course CS 475 taught by Professor Staff during the Fall '08 term at Colorado State.

Ask a homework question - tutors are online