{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

redblack 12 - RED BLACK TREES A RED-BLACK TREE IS ANOTHER...

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

View Full Document Right Arrow Icon
RED BLACK TREES
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
A RED-BLACK TREE IS ANOTHER KIND OF BALANCED BINARY SEARCH TREE.
Background image of page 2
A RED-BLACK TREE IS A BINARY SEARCH TREE IN WHICH THE ROOT ITEM IS COLORED BLACK, EVERY OTHER ITEM IS COLORED RED OR BLACK, AND 1. (RED RULE) A RED ITEM CANNOT HAVE ANY RED CHILDREN; 2. (PATH RULE) THE NUMBER OF BLACK ITEMS IS THE SAME IN ANY PATH FROM THE ROOT ITEM TO AN ITEM WITH NO CHILDREN OR WITH ONE CHILD .
Background image of page 3

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

View Full Document Right Arrow Icon
THE FOLLOWING ARE RED-BLACK TREES:
Background image of page 4
60 30 80 20 50 90
Background image of page 5

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

View Full Document Right Arrow Icon
60 30 80 20 50 90 40
Background image of page 6
WHAT ABOUT THIS? 60 30 80 20 50 90 40
Background image of page 7

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

View Full Document Right Arrow Icon
60 30 80 20 50 90 40 THIS IS NOT A RED-BLACK TREE: THE PATH FROM 60 TO 80 HAS ONLY ONE BLACK ELEMENT!
Background image of page 8
60 30 80 20 50 70 90 ADD 40?
Background image of page 9

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

View Full Document Right Arrow Icon
60 30 80 20 50 70 90 40 ADD 35?
Background image of page 10
60 30 80 20 50 70 90 THIS TREE VIOLATES THE PATH RULE. 40 35
Background image of page 11

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

View Full Document Right Arrow Icon
60 30 80 20 50 70 90 THIS TREE VIOLATES THE RED RULE. 40 35
Background image of page 12
ROTATION TO THE RESCUE!
Background image of page 13

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

View Full Document Right Arrow Icon
60 30 80 20 40 70 90 35 50
Background image of page 14
50 30 90 20 40 80 131 60 85 100 150 140 160 180 THIS RED-BLACK TREE IS NOT AN AVL TREE. WHY?
Background image of page 15

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

View Full Document Right Arrow Icon
CLAIM: THE HEIGHT OF ANY RED- BLACK TREE IS LOGARITHMIC IN n .
Background image of page 16
WHAT IS THE MINIMUM HEIGHT OF A RED-BLACK TREE? 75 40 90 20 60 80 100 10 30 50
Background image of page 17

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

View Full Document Right Arrow Icon
SUPPOSE A RED-BLACK TREE IS COMPLETE, WITH ALL BLACK ELEMENTS, EXCEPT FOR RED LEAVES AT THE LOWEST LEVEL. THEN THE HEIGHT OF THAT TREE IS, APPROXIMATELY, log 2 n .
Background image of page 18
WHAT IS THE MAXIMUM HEIGHT? 50 30 90 20 40 80 131 60 85 100 150 140 160 185
Background image of page 19

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

View Full Document Right Arrow Icon
SUPPOSE A RED-BLACK TREE HAS ALL BLACK ELEMENTS, EXCEPT THAT ONE PATH FROM THE ROOT TO A LEAF HAS AS MANY RED ELEMENTS AS POSSIBLE. THEN THE LENGTH OF THAT PATH, AND THE HEIGHT OF THE TREE, WILL BE MAXIMAL. THE LENGTH OF THAT PATH IS APPROXIMATELY, TWICE THE MINIMAL HEIGHT, SO THE MAXIMUM HEIGHT OF A RED-BLACK TREE WILL BE, ROUGHLY, 2log 2 ( n ).
Background image of page 20
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}