REtree-deletion

REtree-deletion - Deletion in RB trees As with binary...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Deletion in RB trees As with binary trees, we always delete a node that has at least one external child. If the key to remove doesn’t have external children, we swap it with either: 1. predecessor: rightmost child in left subtree. 2. Successor: leftmost child in right subtree. 1: Delete 2: r 2 : delete 8 We can substitute 8 with either the predecessor 7 or with the successor 10.
Background image of page 1

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

View Full DocumentRight Arrow Icon
If the node to remove is attached with a red, substituting the node with an external node will not affect the black height, so “fixing”. What if the incoming edge to the node to remove is black, we will mark the resulting edge as “double black.” (delete 5) Double black edge: an edge that has to be replaced by arranging tree. To fix the double black edge, there are 3 cases: Case#1: Sibling of double black edge is black and one of its children is red. Solution: Perform restructure Find
Background image of page 2
Z:parent of double black edge. Y:node that is sibling to the double black edge.
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

REtree-deletion - Deletion in RB trees As with binary...

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

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