Given a complete binary tree has all possible leaves at level 8 (root at level…

2019

Given a complete binary tree has all possible leaves at level 8 (root at level 0), how many leaves are there?

Answer: B. 256Concept: A perfect binary tree is one where every internal node has exactly two children and every leaf lies at the same depth. In such a tree, the number of…

  1. A.

    128

  2. B.

    256

  3. C.

    512

  4. D.

    1024

Attempted by 156 students.

Show answer & explanation

Correct answer: B

Concept: A perfect binary tree is one where every internal node has exactly two children and every leaf lies at the same depth. In such a tree, the number of nodes present at depth d (root at depth 0) is 2d, because each level exactly doubles the node count of the level directly above it.

  1. The tree is stated to have every leaf at level 8, with the root at level 0. That is exactly the perfect-tree condition -- every node from level 0 through level 7 has two children, and no node exists beyond level 8.

  2. Applying the level-d formula at d = 8: the number of leaves = 28.

  3. 28 = 256, so the tree has 256 leaves.

Cross-check: level 7 must hold 27 = 128 nodes (all internal, each with two children), so the leaf count = 2 x 128 = 256 -- the same result. Note the separate count of INTERNAL nodes only (levels 0 through 7 combined) is 28 - 1 = 255; that internal-node total is one less than the leaf total of 256, and mixing the two up is the usual source of the incorrect figure 255 for this kind of question.

Explore the full course: Niacl Ao It Specialist

Loading lesson…