Consider the following AVL tree. What will be the resultant AVL tree after…
2021
Consider the following AVL tree. What will be the resultant AVL tree after insertion of node with value 20?


Attempted by 313 students.
Show answer & explanation
Step 1: Insert the node with value 20 into the AVL tree. Since 20 is greater than 8 and less than 23, it is inserted as the right child of 8 and left child of 23.
Step 2: After insertion, check the balance factor of each node from the insertion point up to the root. The balance factor of node 14 becomes -2 (left-heavy), indicating an imbalance.
Step 3: The imbalance at node 14 is a Left-Left case (LL), so a single right rotation is performed at node 14.
Step 4: After the right rotation, node 20 becomes the new root of the subtree, with node 8 as its left child and node 14 as its right child. The tree is now balanced.
Step 5: The final tree structure after the insertion and rotation matches the correct option.