Data Structures & AlgorithmsHardGATE CSE · Trees

Keys 50, 30, 70, 20, 40, 60, 80, 35, 45, 25 are inserted into an empty BST in this order. The node 30 is then deleted, being replaced by its inorder successor. What is the level-order traversal of the tree afterwards?

  1. A. 50 25 70 20 40 60 80 35 45
  2. B. 50 40 70 20 45 60 80 25 35
  3. C. 50 35 70 20 40 60 80 25 45
  4. D. 50 20 70 25 40 60 80 35 45

Correct answer: C. 50 35 70 20 40 60 80 25 45

The inorder successor of 30 is 35 (the leftmost node of its right subtree); 35 replaces 30 and its old leaf is removed.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic