AVL Tree

·          
·         Proof: We prove that an AVL tree with height of h has at
·                least Omega(ch) nodes for some constant > 1.
·         Base case: h = 1, AVL tree must have 1 node, so n(1) = 1.
·                    h = 2, AVL tree must have at least 2 nodes,
·                           so n(2) >= 2 >= 22/1
·         Induction step: for h > 2,
·                   n(h) >= 1 + n(h-1) + n(h-2)
·                        > 2 * n(h-2)
·                        >= 2 * 2(h-2)/2
·                        >= 2h/2
·                        >= sqrt(2)h
·             Therefore, if n(h) = N, h <= 2logN.

1.      Single Rotation:

 

2.      Double Rotation I:

3.      Double Rotation II:

1.      No rotation. No change in height. Done.

2.      Single rotation. No change in height. Done.

3.      No rotation. The height decrease by one. Continue up to parent node.

 

 

 

 

4.      Single rotation. Decrease the height by one. Continue up to the parent node.

5.      Double rotation. Decrease the height by one. Continue up to the parent node.