Red-black tree rules:
1, the root node and the leaf nodes are black
2 two child nodes, each node red nodes are black, and vice versa, is not required, in other words there are not two consecutive red nodes
3, the number of black nodes from the root node to the leaf nodes are all on the same
Usually for about red-black tree is given to this definition, it is not easy to think of understanding, and in a book 4 algorithm, skip these rules, and a red-black tree with about 2-3 tree equivalence
If we are to understand the 2-3 tree, understanding the relationship between the red-black tree and 2-3 trees, red-black tree is not difficult to turn around and you will find
2-3 tree:
2-3 trees to meet the basic nature of the binary search tree, but not a binary tree
2-3 tree node can store one element or two elements, each with two nodes (node 2) or three child nodes (node 3), which is 2-3 tree
2-3 tree is an absolute balanced tree
Absolute balance of 2-3 tree:
1,2-3 tree node must not be newly inserted into the empty positions of the nodes
2, if a new node into the node 2, node 3 will form
3, if inserted into a single effort eh node 3, node 4 temporarily formed, then deformed
If this node is the root node, so that treatment is over, if the inserted node is a leaf node
1) The parent node of the node is 2
2) The parent node of the node 3-