fig avl tree case --single rotation is rotation at the pivot node in the opposite direction of the imbalance after the rotation the tree is still binary search tree in additionthe subtree rooted at the pivot will be balanced once againdecreasing its overall height by one figure illustrates this subcase the value is to be inserted into the tree to the left of the node containing howeverdoing so would result in the balance of the node containing to decrease to - which is the closest ancestor with improper balance and the pivot node the yellow node is the bad child in additionthe is being inserted in the same direction as the imbalance the imbalance is on the left and new new value is being inserted on the left the solution is to rotate the subtree rooted at to the rightresulting in the tree pictured in fig subcase bdouble rotation this subcase occurs when the new node is added to the subtree of the bad child which is in the opposite direction of the imbalance for this subcasecall the child node of the bad child which lies on the search path the bad grandchild in some casesthere may not be bad grandchild in fig the bad grandchild is the purple node the solution is as follows perform single rotation at the bad child in the direction of the imbalance perform single rotation at the pivot away from the imbalance fig avl tree case --double rotation this copy belongs to 'acha