You are on page 1of 5

Excercise 4

Hoang Nguyen d117721, Huy Nguyen d117724, Rao Moueed Ahmed d119447
October 19, 2020

1 Exercise 28
a)

b)

1
2
2 Exercise 29

3
4
3 Exercise 30
Node 64 will be the left child of node 70, we simply add it as left node of node 70 and color it red.

Node 85 will be the right child of Node 80, similarly with the case above, we just simply add it as right child
of node 80 and color it red.

Node 66 will be the right child of node 64. But in this case, the black children property of red black tree
has been violated. To fix this, we have to rotate to the left of node 66’s parent which is node 64 and recolor
it. This is the result.

Node 62 will be the left child of node 64.But in this case, the black children property of red black tree has
been violated. To fix this, we recolor its parent as well as its uncle which are node 64 and node 70 to black.
However, simple paths from the root to descendant leaves do not contain the same number of black nodes
(from root to 50 contains 3 but from root to 64 contains 4). So we have to re color node 66 to be red and
node 60 to be black. This is the result.

You might also like