Data Structures & AlgorithmsModerateTCS NQT · Infosys pattern

Keys 50, 30, 70, 20, 40, 60, 80, 35, 65, 10 are inserted into an empty BST. How many nodes have EXACTLY one child?

  1. A. 2
  2. B. 3
  3. C. 4
  4. D. 5

Correct answer: B. 3

20 has only left child 10; 40 has only left child 35; 60 has only right child 65. 50, 30 and 70 have two children; 10, 35, 65 and 80 are leaves. Total 3.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic