Data Structures & AlgorithmsEasyCognizant · Capgemini pattern

What is the maximum number of nodes in a binary tree of height 4, where a single-node tree has height 0?

  1. A. 31
  2. B. 15
  3. C. 16
  4. D. 32

Correct answer: A. 31

Levels 0 to 4 can hold 1 + 2 + 4 + 8 + 16 = 2⁵ − 1 = 31 nodes. 15 = 2⁴ − 1 counts only levels 0 to 3; 16 is the number of nodes at the last level alone.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic