Getting to know data structures

1. Hash table

  www.cnblogs.com/lnu161403214/p/8858236.html

  O(1) search efficiency makes it extremely useful in checking duplicates and judging equivalence

 

2. Trees and Binary Trees

  Implementation of tree: adjacency list method (VECTOR)

  Binary sorting tree: the left child node is less than itself, the right child node is greater than itself, and the ascending sequence is obtained after in-order traversal.

  Huffman binary tree: Store information on leaf nodes, and keep the depth of nodes with high access frequency as low as possible to optimize efficiency. For example: prefix encoding.

  Dictionary tree: Connect all strings to the root node to build a tree.

3. Priority queue and left-biased tree (parallel heap)

  Dynamically maintain the maximum value

Four, and search

  Treat a connected block as a set, and use the root as the symbol of the set

  The weighted union search maintains the relative relationship:

  Each node adds a weight to maintain the relative relationship with the parent node. During the "check" operation, the relative relationship with the grandparent node (tree root) is derived along the parent node. During the "union" operation, the relative relationship with other nodes is passed Relationship, the relative relationship between the two tree roots to be merged is recursively (a bit around --).

  For details, see the classic topic: Food Chain

Five, line segment tree

  The difficulty lies in studying how to efficiently combine the left and right interval solutions

  Common applications of segment trees:

  1) Interval maximum and minimum, interval sum

  2) The largest continuous segment of the interval

  3) The area of ​​the rectangle is unified, and the perimeter is unified

  ☆The lazy flag for interval modification is implemented. When there is a query, the flag is downloaded, which effectively disperses the time complexity.

Six, tree array

  1) The prefix sum is dynamically maintained, the code is very simple, but it can only be modified at a single point

  2) Two-dimensional tree array code is very simple

7. Stretch tree

  (Line segment tree that can delete elements and add elements

Eight, block

  to be continued. . .

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324887157&siteId=291194637