next up previous
Next: RB Trees Up: CSE 2320: Algorithms and Previous: Rotations

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.
, new node is Red; previous nodes are already colored
2.
, new node inserted with NIL (Black) leaves
3.
, parent may also be Red
4.
, 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



Copyright © 1998 The University of Texas at Arlington