Red-Black Tree Insertion (cont)
Re-arrange links/colours after insert:
Step 2 — two consecutive red nodes = newly-created 4-node
Algorithm:
| if both left child and left-left grandchild are red then
| t=rotateRight(t)
| color(t)=BLACK
| color(right(t))=RED
| end if
|
Symmetrically,
- if both right child and right-right grandchild are red
⇒ left rotate t, then re-colour current tree t and left(t)
|