At every step, dynamic programming, easy to understand, enhance thinking

At every step, dynamic programming, easy to understand, enhance thinking

- Chapter III summarizes the algorithm soft three Yang Geng 20181003083

First, at every step, dynamic programming

Similar dynamic programming algorithm to divide and conquer, likened to cite an example of when the last chapter summarizes can be easily understood by thinking of them. However, when you divide and conquer applied on certain issues, it will lead to double-counting problem of high time complexity. In my understanding is that dynamic programming such as filling out a form, first you need to know the bottom of the fill, and then you can fill out the back of the previous According to fill in all the process of taking the best choice.

Divide and conquer the problem is divided into several separate parts, and finally combined; dynamic programming as mentioned above, role and to maintain a record of several parts contact each other.

Design of Dynamic Programming step: to identify the nature of the optimal solution, and characterize structural characteristics, the optimum value defined recursively, bottom-up manner in order to calculate the optimum value, in accordance with the obtained optimum value calculating information constructed most optimal solution.

 

1 the programming problem (longest increasing sequence) recursive equation is as follows:

       Define m [i] is the optimal solution to the end of the i-th (the longest sequence monotonically increasing) one-dimensional tables to fill out the results of this question optimal solution for each step:

       m[i] = max { m[k] + 1 | a[k] < a[i] }

        (1≤k≤i)

 

Programming Question 2 (rented yacht) recursive equation is as follows:

       Define m [i] for the i-th stand to the last stop of the optimal solution (cheapest) used to populate a dimension table:

       m [i] = min {cost [i] [k] + m [k]} (where, cost [i] [k] of the price of the i-th station stations k)

        (i≤k≤n)

 

Second, pair programming, common progress

Recently pair programming results are poor, with less coding time, a strong team-mate, the situation usually ask my teammates. Most dynamic programming problem is very difficult, so I'm very ignorant. Sometimes that'll solve the problem teammates, I can only look at the code to understand and learn do not know where to ask his teammates, played less frequently own code.

Read and understand solution able to understand a question of thinking, and even some of the topics that they can also write recursive equation, but the code will start to knock do not know how to start playing, playing code thinking mess, riddled with mistakes.

Guess you like

Origin www.cnblogs.com/990924991101ywg/p/11785349.html