Red-Black Tree De Nition

Red-Black Tree De Nition

RedBlack Tree Denition Redblack trees have the following prop erties Every no de is colored either red orblack Every leaf NIL p ointer is black If a no de is red then b oth its children are black Every single path from a no de to a decendant leaf contains the same number of black no des What do es this mean If the ro ot of a redblack tree is black can we just color it red No Foroneof its children might b e red If an arbitrary no de is red can we coloritblack No Because now all no des may not have the same black height What tree maximizes the numberofnodes in a tree of black height h What do es a redblack tree with two real no des lo ok like (1) (2) (3) (4) Not consecutive reds Not NonUniform black height RedBlack Tree Height Lemma A redblack tree with n internal no des has height at most lg n Pro of Our strategy rst we bound the number of no des in any subtree then webound the height of any subtree We claim that any subtree ro oted at x has at least bhx internal no des where bhxisthe black height of no de x Pro of byinduction bhx x is a leaf Now assume it is true for all tree with black height bhx If x is black b oth subtrees have black height bhx If x is red the subtrees have black height bhx Therefore the numberof internal no des in any subtree is bhx bhx bhx n Now let h be the height of our redblack tree At least half the no des on any single path from ro ot to leaf must b e black if we ignore the ro ot h h Thus bhx handn so n This implies that lgn hso h lgn Therefore redblack trees have height at most twice optimal We have a balanced search tree if we can maintain the redblack tree structure under insertion and deletion.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    5 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us