lec21 - Red-Black TreesAgain rank(x = black pointers on...

Info icon This preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Red-Black Trees—Again rank(x) = # black pointers on path from x to an external node. Same as #black nodes (excluding x ) from x to an external node. rank(external node) = 0 .
Image of page 1

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

View Full Document Right Arrow Icon
An Example 10 7 8 1 5 30 40 20 25 35 45 60 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 2 1 2 2 3
Image of page 2
Properties Of rank(x) rank(x) = 0 for x an external node. rank(x) = 1 for x parent of external node. p(x) exists => rank(x) <= rank(p(x)) <= rank(x) + 1 . g(x) exists => rank(x) < rank(g(x)) .
Image of page 3

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

View Full Document Right Arrow Icon
Red-Black Tree A binary search tree is a red-black tree iff integer ranks can be assigned to its nodes so as to satisfy the stated 4 properties of rank.
Image of page 4
Relationship Between rank() And Color (p(x),x) is a red pointer iff rank(x) = rank(p(x)) . (p(x),x) is a black pointer iff rank(x) = rank(p(x)) – 1 . Root is black. Other nodes: Red iff pointer from parent is red. Black iff pointer from parent is black. Given rank(root) and node/pointer colors, remaining ranks may be computed on way down.
Image of page 5

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

View Full Document Right Arrow Icon
rank(root) Height <= 2 * rank(root) .
Image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern