Consider the following AVL tree. Root 38; left child 14, right child 56. 14 has children 8 and 23; 23 has left child 18. 56 has children 45 and 82; 82 has…
Consider the following AVL tree.
Root 38; left child 14, right child 56. 14 has children 8 and 23; 23 has left child 18. 56 has children 45 and 82; 82 has left child 70.
What will be the resultant AVL tree after insertion of node with value 20?
Show answerHide answer
Correct answer: (B) Root 38; 14 (children 8, 20); 20 has children 18 and 23; 56 (children 45, 82); 82 has left child 70.
Explanation
20 goes to the right of 18, making 23 unbalanced (left height 2, right 0) with a left-right pattern. An LR double rotation makes 20 the subtree root with 18 and 23 as children, as in option B.