Comments 
Numbers 
Changes in Height from Initial BST 
Initial BST 
Balanced BST  one rotation 
Second rotation 
Left Rotation Unbalanced at 1 N > U N > C left  right = 2 
1 2 3 
U = U  2 
Not needed 

Right Rotation Unbalanced at 3 N < U N < C left  right = 2 
3 2 1 
U = U  2 
Not needed 

RightLeft Rotation Unbalanced at 2 N > U N < C left  right = 2 
2 1 5 4 6 3 
U = U  2 G = G + 1 

LeftRight Rotation Unbalanced at 5 N < U N > C left  right = 2 
5 2 6 1 4 3 
U = U  2 G = G + 1 
44
24 64 16 32 51 88 14 17 28 42 50 54 81 94 12 48 62 78 85
92 96 73 83 86 95 All the nodes in the tree above are balanced. 

We will now add 87 to the tree, and from that
node up, we recompute the heights and balance factors. In this case, we see that node 64 is not balanced since the heights of its children are 3 and 5 respectively. Here, we have labelled those nodes:


Right on C (88):


Now left on U (64):
