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.
 Fall '08
 Staff

Click to edit the document details