We explained the 2-3 tree in the balance lookup tree and the implementation of the red and black tree. 2-3 tree species, a node has a maximum of 2 keys, while the red-black tree uses the staining method to identify the two key.
Wikipedia's definition of B-tree is "in computer science, B-Tree (B-tree) is a tree-like data structure that can store data, sort it, and allow the time complexity of O (log n) to run to find, sequentially read, insert, and delete data structures." B-Tree, generally speaking, a node can have more than 2 child nodes of the two-fork lookup tree. Unlike the self-balanced binary lookup tree, the B-tree optimizes the reading and writing operations of large chunks of data for the system. The b-tree algorithm reduces the intermediate process that is experienced in locating records, thereby speeding the access rate. Widely used in databases and file systems . ”
Defined
A B-tree can be viewed as an extension of the 2-3 lookup tree, which allows each node to have a M-1 child node.
Root node has at least two child nodes
Each node has a M-1 key and is sorted in ascending order
The values of the child nodes of M-1 and M key are between the value corresponding to M-1 and M key
Other nodes have at least M/2 child nodes
The following figure is a m=4-order B-Tree:
You can see that B-tree is an extension of a 2-3 tree that allows more than 2 elements of a node.
B-tree insertion and balancing operation and 2-3 trees are very similar, here is not introduced. The following is inserted into the B-tree, followed by
6 10 4 14 5 11 15 3 2 12 1 7 8 8 6 3 6 21 5 15 15 6 32 23 45 65 7 8 6 5-4
b + tree is a kind of deformation tree for a B. Tree, and its difference from B-tree is:
The nodes with K sub nodes must have K key codes;
Non-leaf nodes only have index function, and information related to records is stored in leaf node.
All leaf nodes of a tree form an ordered list, which can be traversed by the order of key codes.
The following figure is a B + tree:
The difference between B-plus + tree is that the non-leaf node of a + + tree contains only navigation information, does not contain the actual value, all leaf nodes and connected nodes are connected by linked lists, which facilitates the interval lookup and traversal.