Conversion from: http://blogold.chinaunix.net/u2/61062/showart_2039181.html1#:governance method 1.1basic idea Divide and conquer: the original problem (difficult to solve) is divided into several smaller subproblems, and the original problem is solved on the basis of solving each subproblem one by one. 1.2 categoryBased on how to solve the original problem from the decomposed sub-problems, the sub-governance strategy can be divided into two situations: 1. the solution to the original problem only exists in one (or more) subproblem, and only needs to be solved in this (or these) subproblem; exp library for books 2. The solution of the original problem must be obtained by the solution of each subproblem after comprehensive processing. Exp school ratings 1.3 ResultsAppropriate use of the divide and conquer strategy can quickly narrow the scope of problem solving, thus speeding up the problem solving speed. When grouping policies are applied to computer algorithms, subproblems are often decomposed to the same type as the original problems; Compared with the original problem, the size of each subproblem is smaller. This is exactly in line with recursive features. Therefore, the Division Policy in computer algorithms is often associated with recursion. 1.4 typical application of algorithm ideasMaxmin Problems Binary Search Merge and sort Find the smallest K element Multiplication of large Integers Matrix Multiplication Part 2: Basic Idea of governance reduction 2.1Governance reduction technology utilizes a relationship:Solution for a given instance of a problem and for instances with smaller problemsSolutionRelationship. (Using the relationship between understanding, that is, it can reduce the corresponding computing, or it can be said that it is a time-space balance) Once such a relationship is established, we can use the subtraction technology recursively or recursively. 2.2 categoryThere are three main variants of the subtraction and elimination methods: 1. subtract a constant (decrease by a constant) 2. subtract a constant factor (decrease by a constant factor) 3. The scale subtracted is variable (variable size decrease) 2.3 minus a constantIn the constant reduction variant, each algorithm iteration always removes a constant of the same size from the instance scale. In general, this constant is equal to one. FunctionF (n) =AN can be calculated using a recursive definition. F (n) =F (n-1)IfN> 1 =AIfN= 1 Although the time complexity is the same as that of the brute force method, the thought is different! 2.4 minus constant factorThe constant factor reduction technique means that in each iteration of an algorithm, the same constant factor is always subtracted from the instance scale. In most applications, such constant factors are equal to two. ComputingAThe value of N is an instance with a scale of N; If the scale is halved (the constant factor is equal to 2), the instance calculation isAThe value of n/2; There is a clear relationship between them:AN = (AN/2) 2. AN = (AN/2) 2 N is a positive and even number = (A(N-1)/2) 2 a n is an odd number greater than 1 = A n = 1 The above recursion measures the efficiency based on the number of multiplication. This algorithm belongsO(Log N ); Because, at the cost of not more than two multiplications during each iteration, the problem scale will be reduced by at least half. This algorithm is different from the algorithm based on divide and conquer: The grouping algorithm solves two exponential problem instances with n/2 respectively: An =AN/2 *AN/2 If n> 1 = A if n = 1 The time complexity of the division and control method is: O(N) That is to say, divide and conquer are the parts of decomposition that need to be separately calculated (two computations are required), and the rule of reduction uses"Solution for a given instance of a problem and for instances with smaller problemsSolutionThe relationship between them reduces the amount of computing.
2.5 reduction in Variable ScaleUnderVariable Scale reductionIn variants, the scale-down mode varies with the algorithm during each iteration. For example, Euclidean Algorithm 2.6 typical application of algorithm ideas minus a constant:Insert sort Fast sorting (each time a division algorithm is run, only one element is arranged) Deep Priority Search Extended search Topological sorting Generate an arrangement Generate subset Subtract the constant factor:Half Lookup Counterfeit currency issues Variable Scale reduction Binary Search Tree Part 3: Variable governanceThere are three main types of ideas for changing governance based on the Transformation Method of the problem instance: • Transform to a simpler or more convenient instance with the same problem-Instance simplification). • Transform to different performance of the same instance-Representation change ). • An example of another problem. The algorithm for this problem is known-Problem reduction ). Instance simplification Test the uniqueness of elements in the array-instance simplification-pre-sorting Mode computing-instance simplification _ pre-sorting AVL Tree-binary sorting tree Change Performance 2-3Tree,2-3-4Tree-binary sorting tree Heap and heap sorting Horna's Law -- polynomial Computation Problem simplification Knapsack problems-Linear Programming |