Data Structures & AlgorithmsModerateTCS NQT Digital · Infosys

Problem: A binary search tree is built from the values 15, 10, 20, 8, 12, 17, 25 inserted in that order. What is the number of leaves (nodes with no children)?

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

Correct answer: C. 4

The leaves of this BST are 8, 12, 17 and 25. Counting nodes with exactly one child would give a different number.

More Coding Interview Problems questions

Exams that ask this topic