Of The Thought of divide and conquer

What is the basic idea is to divide and conquer?

Design divide and conquer is a big issue will be difficult to directly solve, divided into a number of smaller scale the same problems, so that each break, divide and rule.

More precisely, the size n of the problem is decomposed into k smaller subproblems, and these subproblems independently the same as the original problem. Recursively solve the sub-problems, then de-merge to get the solution of the original problem.

Uses divide and conquer under what circumstances?

Divide and conquer the problem can be solved generally have the following characteristics:

1) the size of the problem is reduced to a certain extent can be easily solved;

2) The problem can be decomposed into a number of smaller problems same problem as the original;

3) sub-problem using the solution of the problem of decomposition can be combined for the solution of the problem;

4) of each sub-problem is the decomposition of the problem are independent, i.e., does not include a common problem among the sub-sub-problems.

Supplementary references from Baidu entry (easy to learn back after understanding greedy algorithm and dynamic programming):

Solution of the problem could be combined to the original solution of the problem is critical, if not have this feature, consider greedy method or a dynamic programming method;

Independent sub-problems related to the efficiency characteristic of divide and conquer, if each sub-question is not independent of the division of work to do a lot of unnecessary therapies, repeatedly solution of common sub-problems, although this time can be used divide and conquer, but generally good dynamic programming method.

Pair programming experience

Encountered obstacles in the process of expression and communication of his teammates, the next point to think about ways to clear.

I hope to improve on the program mainly verbal ability in the future knot, ability to read and understand the code of others, the ability to debug.

 

Guess you like

Origin www.cnblogs.com/Texas/p/11681980.html