B + Tree Concept learning

Source: Internet
Author: User

reprinted since the B-tree, the + + tree, the b* tree talked about the R-Tree

1. The B-tree defined by the order

B-Tree is also called balanced multi-path search tree. a M-Order B-Tree (note: Do not simply think that a M-order B-Tree is a M-fork tree, although there are four-fork tree, eight-fork tree, KD tree, and vp/r tree/r* Tree/r+ tree/x-tree/M-Tree/Segment tree/Hilbert R-Tree/Priority R-Tree, etc. The following features :

      1. Each node in the tree contains a maximum of M children (m>=2);
      2. Root nodes and leaf nodes, each of the other nodes has at least [Ceil (M/2)] Children (where ceil (x) is an upper-bound function);
      3. Joghen nodes are not leaf nodes, there are at least 2 children (special case: No Child root node, that is, the root node is a leaf node, the whole tree has only one root );
      4. All leaf nodes appear on the same layer, and the leaf node has no children and pointers to children, and these nodes exist as well as elements.
Each non-terminal node contains n keyword information: (N,P0,K1,P1,K2,P2,......,KN,PN). which
A) Ki (I=1...N) is the keyword, and the keyword is sorted in ascending order of K (i-1) < Ki.
b) Pi is a contact point pointing to Subtree, and the key of the pointer P (i-1) to all nodes of the subtree is less than Ki, but both are greater than K (i-1).
c) The number of keywords n must satisfy: [Ceil (M/2) -1]<= n <= m-1. Example 1:As shown, that is a B-tree, a key word for the English consonant B-tree, now to find the letter R from the tree species (including n[x] key words x,x have n[x]+1] children (that is, an inner node x if it contains n[x] keywords, then x will contain n[x]+1 children). All leaf nodes are at the same depth, and shaded nodes are the nodes to check when the letter R is found: believe that, from what you can easily see, an inner node x if it contains n[x] keyword, then x will contain n[x]+1 children. If there are 3 children in the inner node with 2 keyword D h, 4 children are included in the inner node with 3 keywords Q T x. Example 2: A storage structure diagram of a 5-order B-Tree containing 24 English letters.

Description:
By definition, in the 5 "m" Order B-Tree, the number of keywords in the root can be 1~4, the number of subtrees can be 2~5; the number of keywords in other nodes can be "[Ceil (M/2) -1]<= n <= m-1", if the node is not a leaf, Then it can have the subtrees tree "[Ceil (M/2)]<=n<=m".

Height of 2.B Tree if a non-leaf node of the B-tree contains n keywords, then this non-leaf node contains n+1 child nodes, and all the leaf junctions are on layer I, we can conclude that:
    1. Since the root has at least two children, there are at least two nodes on the 2nd floor.
    2. Root and leaves, the other nodes have at least ┌m/2┐ children,
    3. So there are at least 2*┌m/2┐ nodes on the 3rd floor.
    4. At least one ┌m/2┐^2 node on the 4th floor.
    5. There is at least a ┌m/2┐^ (L-2) node in layer I, so there are: n+1≥2*┌m/2┐i-2;
    6. Consider the number of nodes in the first layer of n+1, then ┌m/2┐^ (L-2) ≤n+1, that is, the minimum node of the L layer is exactly the n+1, namely: I≤log┌m/2┐ ((n+1)/2) +2;
So
    • When the B-tree contains N keywords, the maximum height of the B-tree is L-1 (because the layer of the leaf node is not counted when the B-tree height is computed), namely: L-1 = log┌m/2┐ ((n+1)/2) +1.
The height formula of the B-tree shows from the side that the B-tree search efficiency is quite high. Asked in an interview, what is the maximum height of a B-tree with an M-order with N total key words? Answer: Log_ceil (M/2) (n+1)/2 + 1 (the 1th feature in the above on M-order B-Tree has been mentioned: each node in the tree contains a maximum of M children, i.e. m satisfies: ceil ( M/2) <= m<=m. Each node in the tree has a smaller number of children, and the height of the tree is greater. 3. B+-tree

B+-tree: It is a b-tree deformation tree which is produced by the file system.

The similarities and differences between a M-order B + tree and a M-order tree are:

1. There are n-1 keywords in the nodes of n subtrees tree; (It is quite controversial, the B + tree in the end is with the tree n subtrees trees have n-1 keyword consistency, or inconsistent: B-tree n subtrees tree node contains n keywords, pending verification. Two reference links are available for the first: ①wikipedia http://en.wikipedia.org/wiki/b%2b_tree#overview;②http://hedengcheng.com/?p=525. )

2. All the leaf nodes contain information about all the keywords, and pointers to the records containing these keywords, and the leaf nodes themselves are linked by the size of the keywords from a large order of origin. (The leaf node of the B-tree does not include all the information it needs to find)

3. all non-terminal nodes can be considered as the index part , and the nodes contain only the largest (or smallest) keywords in the nodes of their sub-roots. (The non-final node of the B-tree also contains valid information that needs to be found)

B + Tree Concept learning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.