Introduction to algorithms-Dynamic Programming)

Source: Internet
Author: User

Dynamic Planning: Solves the entire problem by combining sub-problems.

Four steps for dynamic planning:
1) describe the structure of the optimal solution;
2) recursively define the value of the optimal solution;
3) calculate the value of the optimal solution in an ascending mode (first, find the optimal solution of the sub-problem, solve the sub-problem, and finally find an optimal solution of the problem );
4) construct an optimal solution based on the calculated results.

Two elements of dynamic planning:
1. Optimal sub-structure
If an optimal solution of a problem contains the optimal solution of a subproblem, the problem has an optimal sub-structure. When a problem has an optimal sub-structure, dynamic planning may be applicable.

The optimal sub-structure changes in the problem domain in two ways:
1) Multiple subproblems are used in an optimal solution of the original problem;
2) How many choices are made when determining which sub-problems are used in an optimal solution.

And greedyAlgorithmThe difference: greedy uses the optimal sub-structure in the top-down mode. Greedy first selects the sub-structure. At that time, it seems to be the best choice, and then solves a result sub-problem, instead of looking for the optimal solution of the sub-problem, you can choose again.

2. Overlapping subproblems
When a recursive algorithm continuously calls the same problem, the optimal problem includes overlapping subproblems.
The problems solved by the Division and control method often lead to completely new problems at every step of recursion. Dynamic Planning Algorithms always use overlapping subproblems. That is, each subproblem is solved only once, and the solution is saved in a table that can be viewed as needed. The time of each query table is constant.
When the recursive tree of a natural recursive solution of a problem repeatedly contains the same subproblem, and the number of different subproblems is small, you can consider using dynamic planning to solve the problem.

Dynamic Memory Planning
A kind of deformation of dynamic planning not only has the efficiency of the usual dynamic planning method, but also adopts a top-down strategy.
If all subproblems are calculated at least once, a bottom-up dynamic planning algorithm is a constant factor better than a top-down memory dynamic planning algorithm. However, if there is no need to solve some subproblems In the subproblem space, the memory algorithm is more effective.

FAQs about Dynamic Planning: assembly line scheduling, matrix multiplication, Longest Common subsequence, and knapsack problems.

Reference: Introduction to computing and Development (second edition) Machinery Industry Press

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.