This problem is solved by:
1. First insert in the usual way for a binary search tree either in the left subtree or right subtree. (Duplicates are not allowed in this version.) 2. Check if the heights of the two children subtrees differs by 2. If so, then rotate nodes to restore the AVL properties.
Two rotation methods are needed: rotateLeft or rotateRight.
To rebalance an unbalanced node requires we will need to either do one rotation or two rotations, depending on how the node became unbalanced.