Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: A complete binary tree has 15 nodes (height 3, all levels full). How many of its nodes are leaves?

  1. A. 7
  2. B. 16
  3. C. 4
  4. D. 8

Correct answer: D. 8

A full tree of height 3 has 1 + 2 + 4 + 8 nodes, and the bottom level holds 2³ = 8 leaves. 7 counts the internal nodes, 2⁴ = 16 uses the wrong level, and 4 is the level above.

More Coding Interview Problems questions

Exams that ask this topic