next up previous
Next: Up: Previous:

Insertion

1.
Insert node into tree using BST Insert(T,x) and color node Red
2.
Fix violated RBT properties
3.
Color root Black



Which properties might be violated?

1.
Okay, new node is Red; previous nodes are already colored
2.
Okay, new node inserted with NIL (Black) leaves
3.
VIOLATED, parent may also be Red
4.
Okay, replacing Black node with a Red and Black node



\psfig{figure=figures/f6-18.ps}

  • Tree was balanced before insert
  • If colored Black, may violate property 4


next up previous
Next: Up: Previous: