The first chapter of algorithm overview
Algorithm
Concept: An algorithm is a method or a process that solves a problem.
Properties:
1. Input: 0 or more inputs
2. Output: There is at least one output
3. Certainty: Each instruction that makes up the algorithm is clear and unambiguous
4. Limited: The number of executions per instruction in the algorithm is limited, and the time to execute each instruction is limited.
Program
A program is a specific implementation of an algorithm used in a programming language.
The difference between the algorithm and the program
The algorithm is intended for human reading, and the machine cannot run directly.
The program can not satisfy the H fourth nature of the algorithm--finite.
Complexity of the algorithm
The complexity of the algorithm is reflected in the number of computer resources required to run the algorithm, the more resources required, the more complex the algorithm, the lower the inverse.
Chapter II recursion and the strategy of divide and conquer
Recursive algorithm
An algorithm that calls itself directly or indirectly is called a recursive algorithm
Recursive functions
To give a defined function using the function itself
Divide and conquer the law
The problem of a scale n is decomposed into K small sub-problems, which are independent of each other and the same as the original problem, then solve the sub-problem recursively and then merge the solution of the sub-problem into the solution of the original problem.
The characteristics of the problems that can be solved by the method of divide and conquer
1. The size of the problem can be easily resolved when it is reduced to a certain extent
2. This problem can be decomposed into a number of smaller sub-problems, that is, the "optimal substructure" property
3. The solution of sub-problem can be combined into the original problem
4. Sub-problems are independent of each other, that is, the sub-problem does not include a common sub-problem
Chapter III Dynamic Planning
Memorandum method
The memo method is the deformation of the dynamic programming algorithm. The recursive way of the memo method is top-down, and the solution of each sub-problem is recorded in the process of solving the problem, so the advantage is that it avoids the repetition solution in solving common problems.
Dynamic planning
The original problem is decomposed into several sub-problems, the problem is solved first, the solution is recorded and then the solution of the original problem is obtained from the solution of these sub-problems.
The similarities and differences between dynamic programming and divide-and-conquer method
Same point:
Different points
The fourth chapter greedy algorithm
Fifth Chapter Retrospective method
Sixth chapter method of branch and gauge
A summary of the concept problem of algorithm design and analysis