The notes of Algorithms ---- Dynamic Programming

来源:互联网 发布:下载站源码 编辑:程序博客网 时间:2024/06/05 09:41

Two key ingredients:

#1 Optimal Substructure:

       If an optimal solution to the problem exhibits optimal solution to subproblems.

       Some common pattern:

              1. You show that a solution to the problem consists of making a choice.

                 (choosing an initial cut in a rod or choosing an index at which to split the matrix chain.)

              2. For a given problem. you are given the choice that leads to an optimal solution.

              3. Given this choice, you determine which subproblems ensue and how best characterize the resulting space of subproblems.

              4. You show that the solutions to the subproblems used within an optimal solution to the problem must themselves be optimal by using a "cut-and-paste" technique.


#2 Overlapping Subproblems:

        The total number of distinct subproblems is a polynomial in the input size. When a recursive algorithm revisits the same problem repeatedly.