1 /26
Red-black tree properties
•
Every node in a red-black tree is either black or
red
•
Every null leaf is black
•
No path from a leaf to a root can have two
consecutive red nodes -- i.e. the children of a red
node must be black
•
Every path from a node,
x,
to a descendant leaf
contains the same number of black nodes -- the
“black height” of node
x
.
In these slides we don’t
force the root to be black

This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*
2 /26
Insertion: The First Step
•
Given a new node with a key value, the first step
is to determine where to insert the new node.
•
Since a Red-Black Tree is a Binary Search Tree
(BST), use the BST Insert procedure to:
–
determine the location where the new node’s key value
belongs in the Red-Black Tree.
–
insert the new node at that location.
•
Color the new node
red
.
•
Use the cases described in the following slides to
restore any Red-Black Tree properties that are
violated by the new node.