Divide and conquer strategy for algorithm design and analysis

Where to govern the crowd is like governing the widow, the score is also. ------"The Art of War"

Basic idea of ​​divide and conquer strategy

Divide a big problem that is difficult to solve directly into some smaller, same problems , so that they can be defeated and divided and conquered.

Algorithm design pattern of divide and conquer strategy

Divide_and_Conquer(P){
    
    
	if (|P|<=n0 ) return adhoc(P);
	divide P into smaller substances P1,P2,…,Pk;
	for (i=1; i<=k; k++) 
		yi=Divide_and_Conquer(Pi)	     //递归解决Pi
	Return merge(y1,y2,…,yk)	    //合并子问题
}

Characteristics of problems that can be solved by divide and conquer strategies

  1. The size of the problem can be easily solved by reducing it to a certain extent
  2. The problem can be decomposed into several smaller, identical problems
  3. The solutions of the sub-problems decomposed by the problem can be combined into the solution of the problem
  4. The sub-problems decomposed by the problem are independent of each other

Recommended by other articles in this blog

Algorithm design and analysis of recursive algorithm exercises (part 2)

Algorithm design and analysis of recursive algorithm exercises (on)

Digital triangle problem in algorithm design and analysis

Algorithm design and analysis of ZOJ2104- Let the Balloon Rise

Algorithm design and analysis of priority queue and solution ZOJ1167

Guess you like

Origin blog.csdn.net/L333333333/article/details/102531433