Data Structures & AlgorithmsModerateInfosys · Trees

A complete binary tree stored level by level has exactly 40 nodes. How many of them are leaves?

  1. A. 20
  2. B. 19
  3. C. 21
  4. D. 18

Correct answer: A. 20

The last internal node is at index floor(40/2) = 20, so nodes 21 to 40 are leaves: 20 of them.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic