What is a red-black tree? As the name implies, similar to JuJube, red black tree is a leaf is a black fruit is a red tree ...
Of course, this is what I said ...
That's not what it says in the introduction to algorithms:
If a binary lookup tree satisfies the following red-black nature, then it is a red-black tree.
1) Each node is either red or black.
2) each leaf node (NIL) is black
3) If a node is red, then his two sons are black.
4) The root node is black.
5) For each node, the same number of black nodes are included on all paths from the node to the descendant node.
We will use these properties throughout the process, and of course, for the sake of fairness, even if you do not know the nature, the subject can be completed (why not say it earlier ...). )。 In the various operations of the red and black tree, its core operation is called rotation, then what is rotation, let's look at an example:
Suppose we intercept a part of the red and black tree here, put it on the left, and if we can convert it to the right, then we'll call the tree with the root x as the right hand side, or we'll call the trees with the root y:
Just slow down the board of students to mess up their own red and black trees, and then ask you to help repair, he will describe his red-black tree (chaotic ... )。 Then tell him which way to rotate a node. After you have finished your work, it is good to submit the sequence traversal results of the new tree directly to the rhubarb.
Hint:
Here's a nice slow board classmate to give you a simple explanation of the following example:
At the very beginning, the tree looked like this:
0
/ \
1 2
Then, for the node labeled 0, right-handed, the result becomes:
1
\
0
\
2
And then what...
Middle order traversal? This is something, which one can tell me ....