Question 74Asked in DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 1

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?
  1. ARoot 38; 14 (children 8, 23); 23 has left child 18; 18 has right child 20; 56 (children 45, 82); 82 has left child 70.
  2. BRoot 38; 14 (children 8, 20); 20 has children 18 and 23; 56 (children 45, 82); 82 has left child 70.
  3. CRoot 38; 14 (children 8, 23); 23 has left child 20; 20 has left child 18; 56 (children 45, 82); 82 has left child 70.
  4. DRoot 38; 14 (children 8, 18); 18 has right child 20; 20 has right child 23; 56 (children 45, 82); 82 has left child 70.
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.

From DSSSB TGT Computer Science PYQ (Technical), 1 Aug 2021, Shift 1

This is question 74 of DSSSB TGT Computer Science PYQ (Technical), 1 Aug 2021, Shift 1. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.