Question 16Asked in DSSSB TGT Computer Science (Technical), 8 Aug 2021, Shift 2

Consider a binary search tree given below. Root 14 has left child 10 and right child 16. 10 has left child 7 and right child 13; 13 has left child 11. 16…

Consider a binary search tree given below. Root 14 has left child 10 and right child 16. 10 has left child 7 and right child 13; 13 has left child 11. 16 has right child 20; 20 has left child 18 and right child 25; 25 has left child 22. What is the pre-order traversal of the binary search tree after 14 is deleted?
  1. A7, 10, 11, 13, 16, 18, 20, 22, 25
  2. B16, 10, 7, 13, 11, 20, 18, 25, 22
  3. C16, 7, 10, 13, 11, 18, 22, 20, 25
  4. D25, 20, 22, 18, 11, 13, 10, 16, 7
Show answerHide answer

Correct answer: (B) 16, 10, 7, 13, 11, 20, 18, 25, 22

Explanation

14 has two children, so it is replaced by its in-order successor 16, the smallest key in its right subtree. 16's right child 20 moves up. Pre-order is then 16, 10, 7, 13, 11, 20, 18, 25, 22.

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

This is question 16 of DSSSB TGT Computer Science PYQ (Technical), 8 Aug 2021, Shift 2. 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.