The basic algorithms are divided into the following four categories:
1 , substructure class algorithm: Divide and conquer algorithm, greedy method, dynamic programming
Substructure problem is mainly to know how to solve the problem from the solution of sub-structure problem, the most rough is simple recursion, on the basis of the recursive improvement on the formation of the division, greed and dynamic planning.
Dynamic programming essentially only reduces the iterative solution of sub-structural problems in the recursive process, but it does not reduce the solution space of substructure problems, so there are some problems that using dynamic programming usually do not minimize the time complexity, these problems often require more ingenious solution to achieve the optimal time complexity.
Divide-and-conquer law focuses on the middle
1, dynamic planning focus on the sub-structure from the beginning to consider
2, focus on the introduction of the existing structure from the sub-structure, the need to record sub-structure values
The greedy method focuses on the whole and finds the optimal
2 , search class algorithm: Backtracking method, Branch-bound method Depth-First search Breadth First Search
Search class algorithm The most coarse is the brute force enumeration, the backtracking method is based on the depth-first search, the branch-bound method is established on the basis of the breadth first (the branch bound maintains a priority queue, expands and calculates the priority value according to the breadth priority, then puts in the priority queue and selects the optimal point as the next extension point)
The search class algorithm mainly needs to be clear whether it can be ordered to the poor lifting solution space.
The Dijkstra algorithm is best attributed to the branch gauge, which expands each time the minimum path is selected from the queue
3 , sorting class algorithm:
bubbling, inserting, selecting
Hill, Merge, heap, quick row
Count, base, bucket
4, find the class algorithm:
Traverse Lookup, Binary lookup
Index lookups, hash tables
Introduction to Basic algorithms