-
Dynamic programming algorithms.
It is often used to solve problems with some kind of optimal property. There may be many possible solutions to such problems. Each solution corresponds to a value, and we want to find the solution with the optimal value.
Similar to the divide and conquer method, the basic idea of the dynamic programming algorithm is to decompose the problem to be solved into several sub-problems, solve the sub-problems first, and then obtain the solution of the original problem from the solutions of these sub-problems. Unlike the divide and conquer method, the sub-problems that are suitable for solving problems with dynamic programming are often not independent of each other. If this kind of problem is solved by divide-and-conquer, the number of sub-problems obtained by decomposition is too large, and some of the sub-problems are double-counted many times.
If we can save the answers to the solved sub-problems and find the answers we have already found when needed, we can avoid a lot of double counting and save time. We can use a table to record the answers to all solved sub-problems. Regardless of whether the subproblem is used in the future, as long as it is calculated, its results are populated in the table.
This is known as dynamic programming.
The basic idea. There are many specific dynamic programming algorithms, but they all have the same filling formula.
-
dp must have a state, and greed simply means that there is a situation where the problem can be best solved by satisfying what conditions are met.
In general, dp has to find his state and the equation of transition.
-
The basic idea of dynamic programming is as follows:
Compared with other algorithms, dynamic programming greatly reduces the amount of computation and enriches the calculation results, not only finding the optimal value from the current state to the target state, but also finding the optimal value to the intermediate state, which is very useful for many practical problems. Compared with general algorithms, dynamic programming also has certain disadvantages: it occupies too much space, but for problems with small space requirements, dynamic programming is undoubtedly the best method!
Both dynamic programming algorithms and greedy algorithms are common methods for constructing optimal solutions. The dynamic programming algorithm does not have a fixed problem-solving mode, and the posture preparation technique is very strong.
Compared with other algorithms, dynamic programming greatly reduces the amount of computation and enriches the calculation results, not only finding the optimal value from the current state to the target state, but also finding the optimal value to the intermediate state, which is very useful for many practical problems. Compared with general algorithms, dynamic programming also has certain disadvantages: it occupies too much space, but for problems with small space requirements, dynamic programming is undoubtedly the best method!
Both dynamic programming algorithm and greedy algorithm are common methods for constructing optimal spine-like solutions. The dynamic programming algorithm does not have a fixed problem-solving mode, and it is very skillful.
Dynamic programming is a branch of operations research that is the process of optimizing the decision-making process of solving. In the early 50s of the 20th century, American mathematician Bellman and others put forward the famous optimization principle when studying the optimization problem of multi-stage decision-making process, thus creating dynamic programming.
-
Dynamic programming algorithms.
Similar to the partition method, the basic idea is to decompose the problem to be solved into a number of sub-problems.
However, the subproblems that are decomposed are often not independent of each other. The number of different subproblems is often only on the order of polynomials. When solving with divide and conquer, some sub-problems are double-counted many times.
If you can save the answers to the solved sub-problems and find the answers you have already found when needed, you can avoid a lot of double calculations and get a polynomial-time algorithm.
Solving steps for dynamic programming.
a.Find out the properties of the optimal solution and characterize its structure.
b.Recursively define the optimal value.
c.The optimal value is calculated in a bottom-up fashion.
d.Based on the information obtained when calculating the optimal value, the optimal solution is constructed.
-
a.Calculated from the bottom up.
b.Calculated from the top down.
c.From large to small, the early slow cavity is calculated.
d.Calculate from small to large.
Correct Answer: Lu Shirt AD
-
This problem is no worse than using dynamic programming.
1, 2, 4, 8 ......
A proportional series with n term 2 (n-1) is prepared to meet this requirement.
I've written a piece of dynamic programming that I've experienced here, and it will definitely be helpful to understand it from a simple perspective. >>>More