Personal algorithm notes:
The STL: Standard Template Library Standard Template Library the STL Overview: sequence containers: random data vector array list doubly linked deque bidirectional dynamic queue relationship container: Ordered Data Map SET the multimap multiset has a function of container: CRUD container has functions: structure, destructor, insert, delete, search, copy construction, the number of elements ...... iterator: return address iterator: a container used to locate an element in the array: index list: next pointer container : smart pointers returned by the iterator value: address element of the container is therefore preferable to initialize each use begin () iterator .begin (): the address points to the first element of the iterator .end (): refers to the last element behind container .insert (iterators, data): insert if the container changed, the iterator will fail List: a dynamic two-way linked list array && list: Find an array of efficient chain insertion and deletion efficient array continuous, discontinuous list the deque: Bidirectional dynamic queue between arrays and lists sorting algorithm: sort shell / radix sort / bucket sort shell Sort: insertion sort after optimization 1. 2. In a step grouping step: a step initially set at the number of elements / 2 is inserted into the sorted group 3. 4. step = step / 2 radix sort: 1. Create a temporary array 2. initialize the temporary array 3. sorted temporary array 4. assigning temporary array back to the original value array 5.delete temporary array restrictions: 1. there is no repeated computation 2. space wastage advantages: does not require comparison bucket sort: radix sort upgrade 1. Get the data sorted according to the number range 2. create and initialize the tub 3. traversing a According to sort the array and the array elements exist to a bucket 4. Replace the original array summary: fast Hill sorting speed, unstable quick bucket sort speed, stable, but high spatial complexity divide and conquer: divide and conquer binary search: binary Find merge sort: two ordered arrays into an ordered array merge sort: recursive splitting + merge merge: 1. prepare a temporary array 2. The data sequentially into the temporary array element 3. The data element array back to the original copy from the temporary array, the temporary array is released binary search: an ordered array in accordance with the binary data to find ways recursion: int mid = l + (rl) / 2; // intermediate if return -1 (l == r) ; // not found in the case where, when R & lt == L IF (a == FindData [mID]) return mID; IF (FindData> A [MID]) half_find (A, MID +. 1, R & lt, FindData); IF (FindData <A [MID]) half_find (A, L, MID, FindData); non-recursive method: int MID; int left = L; right = R & lt int; the while (left <right) { MID = left + (right-left) / 2; IF (A == FindData [MID]) return MID; IF (FindData> A [MID]) { left = MID + 1'd; } the else { right = MID; } } return -1; // not found in the case where, when left == right recursive practice of the Tower of Hanoi: IF (NUM <. 1) return; // NUM not match the actual situation han_nuo (num-1, A, C , B); printf ( "% c ->% c \ the n-", A, C); han_nuo (NUM-1, B, A, C); binary search and merge sort summary: are divide and conquer idea dichotomy: every time exclude half the merge: split to become two, recursively split until all becomes an ordered array and then merge ordered array ----> Sort successful N-tree: a tree multiple bifurcation forest: multi tree node: element tree, and subtrees branches, leaf nodes, the path length of the same to some root node path length, same layer: layer change search tree of N additions ordered binary: the binary tree: each node and only two children ordered binary tree: children left <root <right child leaf node: node without children routing algorithm: 1. depth routing algorithm: two-dimensional map: two-dimensional array to identify a specific value on the two-dimensional array as an object on the map RGB widely used in the game Disadvantages: 1 two-dimensional map, you can only walk a straight line 2 may not be able to find the optimal path 2. The breadth pathfinding algorithms: traversing the entire map can go all the points and it will be credited to a quad-tree after tree to start the search from the beginning to the end to find a small summary: depth wayfinding: a back-off cycle less suitable for a broad map may not be able to find the shortest path to the breadth of wayfinding: no rollback cycle and more and apply a small map are sure to find the shortest path but can only go straight 3.A Star wayfinding: structure: N-tree straight slash the cost of the expense: the Pythagorean theorem in line with the price: at every step, from the finish paid f = G + H + W; F: the current point to the end cost g: start point to the current point cost h: current point to estimate the cost of the end point (counting only the linear distance, and ignores disorder) W: weight Road: ground uphill road hilly swamp pit dynamic programming: using dynamic programming: the problem of overlapping sub- optimal value, an optimal solution Fibonacci number problem knapsack problem: when the weight of the backpack == 0: nothing can steal B (i, j): i representatives as well as a few items you can steal j represents the left is how much bag space