Example: (Double left rotation while a new node is added into the AVL tree (RL rotation))
Figure: Double left rotation when a new node is inserted into the AVL tree
A node was added into the subtree C, making the tree off balance through 2 at the root. First we make a right rotation around the node 9, placing the C sub tree in the left child of 9.
Then a left rotation about the root brings node 9 (together its children) up a level and subtree A is pushed down a level (together node 7). Consequently we get correct AVL tree equal balance.
An AVL tree can be represented through the given structure:
struct avl
{
struct node *left;
int info;
int bf;
struct node *right;
};
bf is the balance factor, info is the value into the node.