Introduction to algorithms-Chapter 2-Dynamic Planning

Source: Internet
Author: User

Chapter 4 Dynamic Planning

 

Summary: This chapter introduces the problem of dynamic planning through the assembly line scheduling and matrix chain multiplication, and discusses the longest common subsequence and the optimal binary search tree.

 

1.Dynamic Planning Basics

Dynamic Planning is mainly used to solve the optimization problem. The steps are as follows:

1) Describe the Optimal Solution Structure

2) recursively define the value of the Optimal Solution

3) calculate the value of the optimal solution from the bottom up

4) construct an optimal solution based on the calculated results

 

The idea of dynamic planning is to divide the problem into several sub-problems. The key to obtaining the optimal solution is to find the optimal sub-structure.

The running time of the dynamic planning algorithm depends on the product of two factors: the total number of subproblems and the number of choices for each subproblem.

 

Can two marks of dynamic planning be adopted: optimal sub-structure and overlapping sub-Problems?

 

Optimal sub-structure:The optimal solution of a problem includes an optimal solution of a subproblem.

Dynamic Planning uses the optimal sub-structure in a bottom-up manner

Condition for applying the optimal sub-structure: the sub-problem must be independent, that is, the solution of a sub-problem does not affect the solution of another sub-Problem of the same problem. If the sub-Problems of the same problem do not share resources, they are independent.

 

Overlapping subproblems:Recursive Algorithms used to solve the original problem can repeatedly solve the same subproblem.

 

Memorandum

A kind of deformation of Dynamic Planning adopts a top-down strategy. Maintain a table that records sub-problem solutions, but the control structure for table filling is more like a recursive algorithm.

 

Comparison between dynamic planning and Memorandum:

If all sub-problems must be calculated at least once, a bottom-up dynamic planning algorithm generates a constant factor better than a top-down memorandum algorithm, because the former does not require recursion, and table maintenance costs are lower. If there is no need to solve some subproblems In the subproblem space, the memorandum method has the advantages of solving only those subproblems that must be solved.

 

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.