Use the conventional bottom-up red-black tree insertion: insert a red node by the binary search tree rule, repair a red parent with recolouring or tree rotations, and make the root black. Write and for black and red. The first three insertions give root , with on the left and on the right.
Inserting as the left child of gives a red parent and a red uncle. Recolour black and retain a black root . Inserting then gives the inner configuration ––. A left tree rotation at , followed by a right tree rotation at , produces a subtree rooted at with and beneath it. Finally insert to the left of . Its uncle is red, so recolour black and red. No further repair is required because has black parent .
The final root is ; its left child is and its right child is . Under are on the left and on the right; has left child . All omitted children are black null sentinels. Each root-to-null graph path has two real black nodes, and no red node has a red child.
Figure 1.
The red-black tree after the six insertions, with colours also marked B and R
. Details.

Articles by others on the same topic (0)

There are currently no matching articles.