AVL Tree Visualization

AVL Tree

AVL tree is enhancement version of binary search tree. we know that avl tree is height balance tree. more information about avl tree .

Balance Factor

Balance factor of avl tree node is depends upon height of right subtree and height of left sub tree.

Balance Factor of Node :(height of right subtree)-(height of left subtree).

Height Representation

Height of node  is : 1

Height of node  is : 0

Height of node  is : 0

Height of node  is : 0

Height of node  is : 0

C program to find Height of tree

Valid balance Factor

Valid balance factor of AVl tree are [ 0 , 1, -1] . If get other balance factor that means to need rotate avl tree node.

Show balance factor

Rotation Of AVL Tree

4 Rotation of AVL tree

LL Rotation

LR Rotation

RL Rotation

RL Rotation

LL Rotation

This is basic example to LL rotation. Now actual visualization on this given avl tree with NULL representation on Left and Right child.

After LL Rotation [view rotation]

Step 1: In this example root are involved to LL rotation. that means modifying root of tree. use one hold pointer variable that is pointed to left child of root.

Step 2: Modifying the change of root node left child.

Step 3: Change the link of hold pointer right_child to this root node.

Step 3: Change root node.

Step 4: Final change blance Factor.

After LR Rotation [view rotation]

Above perform AVL Tree all Operation.