Data Structures & AlgorithmsHardTCS NQT · Infosys

Problem: The binary search tree is built by inserting 8, 3, 10, 1, 6, 14, 4, 7, 13 in this order. How many nodes lie at the maximum depth of this tree (root at depth 0)?

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

Correct answer: B. 3

Count nodes per depth with a traversal carrying the depth, then report the count at the deepest level. Counting leaves instead of nodes at the deepest level gives a different number when depths differ.

More Coding Interview Problems questions

Exams that ask this topic