The path of algorithm re-picking--Dynamic programming Foundation

Source: Internet
Author: User

*************************************** Reprint Please specify the Source: Http://blog.csdn.net/lttree ********************************************




Chat : Almost to the end of the semester, as a computer major junior students, all kinds of big jobs, to the junior, no longer confined to the exam, the school is more attention to practical ability, so all kinds of big homework ah, parallel computing, software engineering, software integrated design and so on, some things, requirements to do, in the first two years, not learned, So to learn, the basic time to squeeze dry, this book read a lot, is that there is no time to update. Keep working on it!



these two chapters Dynamic Planning



1. Basic Ideas

The basic idea of dynamic programming is also to decompose the problem into several sub-problems, first seek the sub-problem, and then get the solution of the original problem from the solution of these sub-problems.

However, different from the division of the law: after the decomposition of sub-problems, often not independent of each other. (Divide and conquer the law often will have some sub-problems, repeated calculation, dynamic planning, with a table to record all resolved sub-problem answers, no matter how useless, as long as the calculation, save it)



2. Step by step

Steps to solve a dynamic programming problem:

1) Identify the nature of the optimal solution and characterize its structure

2) define the optimal value recursively

3) Calculate the optimal value in a bottom-up manner

4) The optimal solution is constructed according to the information obtained when calculating the optimal value.

< steps 1 ~ 3 above are the basic steps of the dynamic programming algorithm. In the case where only the optimal value is required, it is sufficient to use the 4来, if the problem is the optimal solution, then the steps need help. >

PS: On the optimal value and the optimal solution: take the matrix multiplication as an example, if the final request at least how many times to multiply, that is the optimal value; if the last request, the least times multiplication is how to pair the parentheses to multiply, this is the optimal solution)



3. Two Brothers

> Brothers: Optimal substructure:

· The first step in designing a dynamic programming algorithm is usually to characterize the structure of the optimal solution.

· When the optimal solution of a problem contains the optimal solution of its sub-problem, it is said that the problem has the optimal sub-structure property.

· When analyzing whether an issue has optimal substructure properties, the method used is universal:

First, it is assumed that the solution of the sub-problem derived from the optimal solution of the problem is not optimal, and then try to show that the solution can be constructed better than the original problem under this hypothesis, which leads to the contradiction.

• Use the optimal substructure properties of the problem to from bottom up the optimal solution of the whole problem is constructed recursively from the optimal solution of sub-problem.

> Brothers: Overlapping sub-issues

· When using recursive algorithm to solve the problem from top to bottom, the sub-problem is not always a new problem, and some sub-problems are counted repeatedly. Dynamic regulation cost-effective method is the use of this seed problem overlapping nature, for each sub-problem, only one time, will be stored in the table, the next time, to view the table directly.



4. The Memorandum of Deformation Act

The memo method is the deformation of the dynamic programming algorithm, and as with dynamic programming, the memo method is also the answer to storing sub-problems with tables. However, unlike the normal dynamic programming approach, the recursive approach of the memo method is top-down, while the dynamic programming algorithm is bottom-up.

Therefore, the control structure of the memo method is the same as the control structure of the direct recursion, except that the memo method has a table to store the answer to the sub-question.

Generally speaking, it is better to use the dynamic programming method than the memo method when all the sub-problems of a problem are at least solved. At this point, the dynamic planning algorithm does not have any redundant computations. It is advantageous to use the memo method when the problem of sub-problem is not solved in the middle of space.




*************************************** Reprint Please specify the Source: Http://blog.csdn.net/lttree ********************************************

The path of algorithm re-picking--Dynamic programming Foundation

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.