B-tree and B + tree notes

B-tree and B + trees are all multi-branch balanced search tree, such as the query time complexity of O (logN).

 

B-tree:

Tree nodes: Record - key (index in the database), the pointer corresponding to the record key pointer child node.

Keywords: indexes in the database, each tree node key number is greater than 1 less than the recording tree M.

Key corresponding record pointer: a pointer based on the database can be queried directly to the database record corresponding to the index.

Child node pointer: a pointer based on the size of the query keyword child node, a child node in the middle of the two parent nodes keywords.

 

B + tree:

Non-leaf node of the tree: Record - key (index database), the child node pointer, no data record corresponding to the keyword .

Leaf node: Record - key (of the index database), data corresponding to the keyword (clustered index: a pointer to the record corresponding to the index; non-clustered index: cluster index corresponding to the index, and by the return the clustered index table corresponding to the query data)

Keywords: indexes in the database, each tree node key number is greater than 1 less than the recording tree M.

Child node pointer: a pointer based on the size of the query keyword child node, a child node in the middle of the two parent nodes keywords.

 

B-tree advantage: when the B-tree data query, if the query of the data from close to the root node, the tree node and a corresponding record in the record pointer, it is possible to more quickly acquire the piece of data, without traversing to leaf nodes.

Advantage of the B + tree: a non-leaf node is not recorded in the record pointer corresponding to the index, so more space can be used to store the index record, reducing the height of the tree, can quickly query.

       2. All key data are recorded in the leaf node, so the query speed stability (need to traverse leaf).

                      3. Full node traversal faster, traversing the linked list rather than traverse the tree leaves.

Guess you like

Origin www.cnblogs.com/ybonfire/p/11742073.html