Algorithm Analysis (CSC 301 2015F) : EBoards

CSC301.01 2015F, Class 12: Red-Black Trees


Overview

Preliminaries

Admin

Upcoming Work

Extra Credit

Academic

Peer

Questions

Balancing (or at least rearranging) balanced trees

We had

      a (N+2)
     / \
    /   \
 b(N+1) C(N)
  /  \
 /    \
D(N)  E(N)

We added a node below D which increased its height by 1.

        a (N+3)
       / \
      /   \
   b(N+2) C(N)
    /  \
   /    \
D(N+1)  E(N)

Questions

Red-black tree basics

How imbalanced can such a tree be? How do we compute the black height of a node?

Red-black tree examples

Insertion in red-black trees

We insert in the normal bst model. We color the new leaf red and then clean up.

Examples of things we'll have to deal with. Assume b and r are the old black and red nodes, and R is the new red node.

           b
          / \
         /   \
        b     b
       / \
      /   \
     r     r
    /
   /
  R