notes82

notes82 - CS 251 Midterm No Class CS 251 Remove R/B...

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

View Full Document Right Arrow Icon
CS 251 March 28, 2004 Midterm - No Class CS 251 March 30, 2004 Remove - R/B Trees (summary) Always remove keys in the bottom nodes If the key to remove is not in the bottom row, swap with the right most node in the left subtree If the incoming edge is red, just remove. There is no need to rearrange. Black height is still the same. However, if the incoming node is edge is black, the black height will change upon removal, so we need to fix the path to the root. Fixing the Path to the Root - Three Cases Case 1 The sibling of the double black edge is black and one of its children is red. A restructuring is in order. Find z,y,x z - parent of double black edge y - node sibling to double black edge x - node connected to y through red edges Label x,y,x as A,B,C based on in order visit and rearrange
Background image of page 1

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

View Full Document Right Arrow Icon
Case 2 The sibling of the double black edge is black and its children are black. A recolor is in order. If the edge to the parent is red then the double black gets distributed as shown in Case 2a. If the edge to the parent is black the double
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.

{[ snackBarMessage ]}

Page1 / 7

notes82 - CS 251 Midterm No Class CS 251 Remove R/B...

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