Storing values of sub solutions construct the optimum

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

View Full Document Right Arrow Icon
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 define 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

{[ snackBarMessage ]}

Ask a homework question - tutors are online