Data Structures & AlgorithmsModerateTCS NQT Digital · Infosys

Problem: Starting from the empty set, a process inserts the numbers 5, 3, 8, 1, 4, 7 into a binary search tree, and then deletes nothing. How many nodes lie in the left subtree of the root?

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

Correct answer: C. 3

The root is 5; values below it (3, 1, 4) form the left subtree. Counting all nodes in the tree instead of the left subtree gives 6.

More Coding Interview Problems questions

Exams that ask this topic