Dynamic Programming - understand the nature of the article Dynamic Programming

Dynamic programming is often a difficult problem. Let me share a V-written articles, we will look at other people's understanding of the dynamic programming:

https://www.zhihu.com/question/23995189/answer/1094101149?utm_source=com.tencent.tim&utm_medium=social&utm_oi=732325277794836480

Inside this article: given a very important point: the face of a dynamic programming problem:

first step:

It is the most important step: the definition of d [i] (one-dimensional dynamic programming) or d [i] [j] and clearly know its meaning! This step is very important, and some topics can be seen directly, and some of the topics that we need to dig their own refining

Part II:

The definition of the state transition equation:

For one-dimensional dynamic programming, that is, d [i] and d [i-1] or a further d [i-2] (usually is d [i] and d [i-1], d [i- 2 relationship] relationship) a;

Two-dimensional dynamic programming, is d [i] [j] with d [i-1] [j-1] or d [i] [j-1] or d [i-1] [j] or d [i -1] [j + 1] or d [i + 1] [relationship j-1] is.

That it is, in essence, is to define the relationship between the transfer current state and neighboring states. Here we need to be fully recognized that due to d [i] or d [i] [J] to determine the meaning of, the physical meaning of the current state and a state which is the same as described

third step:

According to the state transition relationship established boundaries:

Generally for one-dimensional case, we will establish d [0], d [1]; for two-dimensional case, will establish d [0] [0 ... n-1] and d [0 ... n-1 ] [0] or d [i] [i] (diagonal), which is two-dimensional, it is generally established that the boundary line of the first column or the first diagonal (dp is a two-dimensional matrix)

 

Order of the above three steps, please do not mistake, in strict accordance with the above three steps for solving dynamic programming problems! ! ! !

 

Experience: Most of the topics usually require two-dimensional dp, particularly issues related to the string, ninety percent of all two-dimensional dp; dp is usually a one-dimensional array class.

The above three steps done, basically you're done!

Guess you like

Origin www.cnblogs.com/shaonianpi/p/12577296.html