Data Structures & AlgorithmsHardGATE CSE · Trees

In a binary tree every node has 0 or 2 children, except 7 nodes that have exactly one child, and there are 12 nodes with two children. How many nodes does the tree have in total?

  1. A. 31
  2. B. 30
  3. C. 25
  4. D. 32

Correct answer: D. 32

Leaves = (nodes with two children) + 1 = 13, so the total is 13 + 7 + 12 = 32.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic