General thinking of solving problems in dynamic programming

Source: Internet
Author: User
* Many problems of finding optimal solutions can be solved by dynamic programming. * First, the original problem should be decomposed into several sub-problems. Note that simple recursion often causes sub-problems to be repeated, with the method of dynamic programming, once the solution of sub-problem is saved, so each sub-problem is solved only once. * Sub-problems are often similar to the original problem, sometimes even exactly the same, except that the scale changed from N to N-1, or from the original NXM to NX (m-1) ... Wait a minute. * Finding sub-problems means finding a way to decompose the whole problem gradually. * Break down until the smallest sub-problem at the bottom of the scale can be seen at a glance. * Each layer of sub-problem resolution, will lead to the resolution of the previous layer of sub-problem, layered upward, will lead to the final resolution of the whole problem. * If starting from the bottom of the sub-problem, from the bottom up to derive a sub-problem of the solution, then the programming time does not need to write recursive function. * When solving problems with dynamic programming, a set of variables related to sub-problems is called a "state". A "state" corresponds to one or more sub-problems, the so-called "state" under the "value" is the "state" corresponding to the sub-problem of the solution. * For example, the number triangle, the sub-problem is "starting from the (r,j) number, in the end the maximum and the edge path." This sub-problem is related to the two variables R and J, then a "state" is a set of values for R, J, i.e. the position of each number is a "state". The "value" corresponding to the "state" is the sum of the numbers on the best path of the edge, starting with the number in that position. * Define what is "state" and "value" under that state to find out how different states are migrated-that is, how to calculate the value of another state from one or more known "states" of value. The migration of States can be expressed by recursive formulas, which can also be called "state transition Equations". * Using dynamic programming to solve problems, how to find "sub-problems", the definition of "state", "state transfer equation" is what kind of, and no fixed pattern, the need for concrete analysis of specific problems, the topic will have a feeling. * Even, for the same problem, there may be more than one way to break up a sub-problem, so the "state" can have different ways of defining it. Different "state" definition methods may lead to differences in time and space efficiency.

General thinking of solving problems in dynamic programming

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.