Steps for insertion in AVL trees -
Insert the new node as in a normal binary search tree (BST).
Move back up the tree and calculate the balance factor for each node:
balance factor = height of left subtree - height of right subtree.
If the balance factor becomes greater than 1 or less than -1 (means balance factor should be -1, 0, +1), the tree is unbalanced and needs rotation.
There are four types of rotation which include -
Left left (LL) rotation - when a node is inserted in the left subtree of the left child.
Right right (RR) rotation - when a node is inserted into the right subtree of the right child.
Left right (LR) rotation - when a node is inserted into the right subtree of the left child.
Right left (RL) rotation - when a node is inserted in the left subtree of the right child.
For example, this is a balanced AVL tree -