rb_example1 - Red-black tree properties Every node in a...

Info icon This preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
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
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
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.
Image of page 2