GATE Computer ScienceVery hardGATE CSE · UGC NET

Keys 50, 30, 70, 20, 40, 60, 80, 35, 45, 65, 10, 25, 75 are inserted in this order into an initially empty BST. Then key 30 is deleted, then key 50. A node with two children is replaced by its inorder successor (which is then removed from its old place). What is the 6th key in the preorder traversal of the final tree?

  1. A. 25
  2. B. 45
  3. C. 40
  4. D. 70

Correct answer: C. 40

After both deletions the preorder is 60, 35, 20, 10, 25, 40, 45, 70, 65, 80, 75; its 6th entry is 40.

More Programming and Data Structures (GATE) questions

Exams that ask this topic