Insert into AVL tree, perform rotations to restore balance
Analyze the insert into avl tree, perform rotations to restore balance.
Examples
Input:"test_input_1"
Output:"output_1"
Input:"test_input_2"
Output:"output_2"
Hints
Recall the four possible imbalance cases in an AVL tree (LL, RR, LR, RL) and the corresponding rotations needed to fix them.
After inserting a node, trace the path from the inserted node back to the root, updating heights and checking balance factors at each step.
Implement the insertion recursively, then handle rotations by carefully updating the root pointers of the affected subtrees while maintaining the BST property.
Insert into AVL tree, perform rotations to restore balance
Analyze the insert into avl tree, perform rotations to restore balance.