rb_delete_example

rb_delete_example - Red-black tree properties Every node in...

Info iconThis preview shows pages 1–3. 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
Background image of page 1

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

View Full DocumentRight Arrow Icon
2/26 Deletion: The Main Idea We are given a pointer to the node z to be deleted. Since a Red-Black Tree is a Binary Search Tree (BST), use the BST Delete procedure to: splice out a node y locate x, which is either y’s sole non-sentinel child before y was spliced out, or the sentinel, if y had no children. If y is red, no problem, so stop. If y is black, give x an “extra black.” If x is “red-black,” turn it into a black node and stop. If x is “black-black ”, use the 4 cases described in the textbook (and there are 4 symmetric
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

rb_delete_example - Red-black tree properties Every node in...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online