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

• Notes
• 29

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

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 .

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

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
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)) .

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

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.
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.

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

rank(root) Height <= 2 * rank(root) .
This is the end of the preview. Sign up to access the rest of the document.
• Spring '10
• sartajsahani
• Rank

{[ snackBarMessage ]}

### What students are saying

• 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.

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

• 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.

Dana University of Pennsylvania ‘17, Course Hero Intern

• 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.

Jill Tulane University ‘16, Course Hero Intern