A full binary tree with n leaves contains

2009

A full binary tree with n leaves contains

Answer: C. 2n –1 nodesKey fact: in a full binary tree every internal node has exactly two children. Let n be the number of leaves (denote leaves by L = n) and let I be the number…

  1. A.

    n nodes

  2. B.

    log2 n nodes

  3. C.

    2n –1 nodes

  4. D.

    2n nodes

Attempted by 58 students.

Show answer & explanation

Correct answer: C

Key fact: in a full binary tree every internal node has exactly two children.

  1. Let n be the number of leaves (denote leaves by L = n) and let I be the number of internal nodes.

  2. Each internal node has two children, so counting parent→child edges gives 2I edges coming from internal nodes.

  3. Every node except the root has exactly one parent, so the total number of edges is the total number of nodes minus one: (I + L) − 1.

  4. Equate the two counts of edges: 2I = (I + L) − 1. Solving gives I = L − 1.

  5. Total nodes N = I + L = (L − 1) + L = 2L − 1. Substituting L = n yields N = 2n − 1.

Conclusion: a full binary tree with n leaves contains 2n − 1 nodes.

Explore the full course: Coal India Management Trainee

Loading lesson…