Several Tree

1. The binary search tree or a binary sort tree (BST)
Nature: key is smaller than the left subtree of the root key, the key is greater than the right subtree of the root key.


2. balanced binary tree (AVL Tree)
the absolute value of which is an empty tree or sub-tree of its left and right height difference of not more than 1, and left and right sub-trees are a balanced binary tree.
Add or delete a node in the AVL tree AVL tree can cause loss of balance, there are four cases: LL, LR, RL, RR
X2 root X1 (L or R) child node (L or R) child node contains a non-empty node resulting in a binary tree loss of balance
solution:
  LL (inserted into the left child of the left subtree): D-
  LR (inserted into the left and right child subtree): first around the left child node of L-root, root around and then right-
  RR (inserted into the right child of the left subtree): L
  RL (inserted into the right child of the right sub-tree): right-handed around to the right child node of the root node, and then left around the root


3. A red-black tree
a self-balancing binary search tree
  1) node is red or black.  
  2) the root is black.
  3) each leaf node are black empty node (NIL node).
  Two children 4) each red node are black. (From each leaf can not have two consecutive red nodes on all paths to the root)
  5) from any node to all leaves of each path contains the same number of black nodes.
To ensure the self-balancing of the red-black trees, red-black tree from the root node to the leaf node of the longest path does not exceed 2 times the shortest path
needs to be adjusted (the situation is more complicated) or discolored by rotating the insertion or deletion


4. balance multiple search tree (B-Tree, Tree Balance)
B-Tree is a balanced search tree is loaded with the disk storage devices designed to reduce the number of accesses to disk I / O is
mainly used file system and database index portion , such as: non-relational databases MangoDB
m-order B-tree features: (k∈ [m / 2, m])
  . 1) has at least two sub-root node
  2) k sub-tree, the number of elements in the node. 1-K
  . 3) all leaf nodes at the same level (Ilex)
  4) in each node in ascending order elements


+ tree 5.B
most relational databases using a B + tree index, such as the MySQL
B + tree is based on a B-tree An optimized, making it more suitable to achieve the outer structure to store the index
m-order B-tree features: (k∈ [m / 2, m])
  . 1) K sub-tree, the node is the number of elements K,
  2) each element does not save data, only used the index, all data is stored in the leaf nodes.
  All leaf nodes contains information of all the elements, and these elements contain pointers to records,
  and the leaf node itself according to the size and large keyword brought sequentially linked.
  3) All the intermediate node element, exists in the child node, is the largest (or smallest element in the sub-node) elements

 

Guess you like

Origin www.cnblogs.com/mznsndy/p/11646910.html