Algorithm design and analysis---Algorithm overview

Algorithm overview

1. Algorithms and procedures

1. The concept of algorithm: an algorithm is a finite sequence composed of several instructions and meets 4 properties:
1) Input: 0 or more externally provided quantities are used as the input of the algorithm;
2) Output: the algorithm is at least A quantity is the most output;
3) Determinism: Each instruction that makes up the algorithm is clear and unambiguous;
4) Finiteness: The number of executions of each instruction in the algorithm is limited, and the execution time is also limited;
2. The difference between
a program and an algorithm : the program may not satisfy 4), for example, the operating system is a program rather than an algorithm, and the operating system is a program that executes in an infinite loop;

2. Algorithm complexity analysis

1. Algorithm complexity is divided into time complexity and space complexity.
2. Time complexity refers to how much time resources the algorithm occupies;
3. Space complexity refers to how much space resources the algorithm occupies;
4. The complexity is based on The worst complexity prevails!
If the time complexity of a problem can be expressed in polynomial form, then the time complexity is equal to the highest order of the polynomial.
For example, the time complexity T(n)=4 n^3+3 logn+2;
then T(n) is approximately equal to 4*n^3;
Symbolic definition:

1)O(f)+O(g)=O(max(f,g));
2)O(f)+O(g)=O(f+g);
3)O(f)*O(g)=O(f*g);
4)如果g(N)=O(f(N))则有O(f)+O(g)=O(f);
5)O(Cf(N))=O(f(N))(C是正常数);
6)f=O(f);

3. NP completeness theory

1. Turing halting problem: the problem
cannot be solved in polynomial time, that is, if there is no constant k, the problem is solved in O(n^k);
2. Type P problems:
all decision problems that can be solved in polynomial time Form P-type problems (polynomial problems);
3. NP-type problems:
non-deterministic polynomial problems;
4. Cook theorem: the satisfiability problem of
Boolean expressions SAT is NP-complete;
5. Several classics in the NP- complete problem tree The NP-complete problem:
1) The satisfiability problem of conjunctive paradigm CNF-SAT;
2) The satisfiability problem of ternary conjunctive paradigm 3-SAT;
3) The clique problem CLIQUE;
4) The vertex cover problem VERTEX-COVER;
5) Subset and problem SUBSET-SUM;
6) Hamilton circuit problem HAM-CYCLE;
7) Traveling salesperson problem TSP;

Guess you like

Origin blog.csdn.net/timelessx_x/article/details/115260940