I. Recursive algorithm
Recursive algorithm: It is a process that calls itself directly or indirectly, but the size of each invocation of the problem is reduced, and the problem is resolved in the end.
The idea of recursive algorithm comes from the method of division and treatment.
Divide-and-conquer law: to divide a big problem which is difficult to solve is divided into several smaller problems in order to conquer, divide and conquer.
Common recursive algorithms, such as:
int fun (int n) {if (n==0| | n==1) return 1;elsereturn n*fun (n-1);}
Two. Sorting algorithms
You can refer to the previous blog:
http://blog.csdn.net/qzp1991/article/details/42002063
Three. Dynamic planning
Common problems include the sequential problem of matrix multiplication and the construction of optimal binary tree.
Four. String matching issues
Two kinds of algorithms
KMP algorithm: http://blog.csdn.net/qzp1991/article/details/42660437
BM algorithm: http://blog.csdn.net/qzp1991/article/details/42663969
Five. NP problem
It is a problem can be solved in polynomial time, such problems have not yet developed a reasonable fast algorithm.
Such as
Knapsack problem: Give n size items s1,s2 ... SN and C-capacity backpack, can find n items to fill the backpack as far as possible.
Packing problem: There are countless boxes, each box has a capacity of 1, there are n items, each item's volume is S1,S2...SN (sn<1), to accommodate the minimum number of boxes of these items (optimization problem) or given a positive integer k, can put these items into the K box (decision problem).
Hamilton Road: In an no-map, the Hamiltonian is a simple path that contains all the nodes and has only one time after each node.
Classification of common algorithm problems