Scenario: Resolve a lookup in a large amount of data on the hard disk. Because a large amount of data is stored in the hard disk, can not be loaded into memory all at once, and each time a data read the hard disk, reading speed is too slow, it is necessary to use a part of a data structure read in, this is the role of multi-path search tree. 2-3 Trees
2 nodes: Each of the points contains one element and two children (or no children). Where the left child is less than the node element, the right child is larger than the node element.
3 nodes: Each node consists of two elements and three children (or no children). Where the left child is less than the smaller element in the node, the child is larger than the smaller element, and the right child is larger than the larger element.
2-3 Tree: A tree consisting of 2 nodes and 3 nodes, and all leaf nodes are 2-3-4 on the same layer
2-3 the expansion of the tree, added 4 nodes, containing a small medium-large three elements and four children spread over three spatial ranges divided by these four elements. B-Tree
B-Tree is similar to 2-3 tree and 2-3-4 tree, the maximum number of children is called the Order of B-tree, each node of B-Tree is more than the original node that indicates the number of elements of the storage space. The Order of the general B-tree is very large.
Advantages: Easy to find, each node is stored in the corresponding hard disk page, each time read a node and key value comparison, and then determine the next time to read which node.
Cons: When you need to do a mid-order traversal, we need to go back and forth between each node (that is, the middle sequence traverses the left child to the parent node and then to the left child to the right), which causes multiple hard drive accesses and slows down. That's the need to use B + Tree B + Tree
Solve the basic problem of element traversal.
B + Tree: Breaks the principle that each element of a tree species appears only once, adding elements from other intermediate nodes on each leaf node. That is, the leaf contains all the original node information, and contains the index of the successor leaf node.
Pros: Especially suitable for a range of lookups.
The database uses a B + tree lookup.