A binary tree T has n leaf nodes. The number of nodes of degree 2 in T is

1995

A binary tree T has n leaf nodes. The number of nodes of degree 2 in T is

  1. A.

    log₂n

  2. B.

    n-1

  3. C.

    n

  4. D.

    2ⁿ

Attempted by 177 students.

Show answer & explanation

Correct answer: B

In any non-empty binary tree, there is a fundamental relationship between the number of leaf nodes (degree 0) and the number of internal nodes with two children (degree 2). Let L represent the number of leaf nodes and N₂ represent the number of degree 2 nodes. The total number of edges in a tree with n_total nodes is always n_total - 1. Alternatively, counting edges by node degrees gives: Total Edges = (0 × L) + (1 × N₁) + (2 × N₂), where N₁ is the number of degree 1 nodes. However, a simpler property holds for full binary trees or general binary trees where we consider the relationship between leaves and degree 2 nodes specifically. For a binary tree, the number of leaf nodes is always exactly one greater than the number of degree 2 nodes. Therefore, if there are n leaf nodes, the number of degree 2 nodes must be n - 1. Option A (log₂n) is incorrect because it describes the height of a balanced tree, not node counts. Option C (n) is incorrect because it suggests an equal count, which violates the tree structure property. Option D (2ⁿ) is incorrect as it grows exponentially and does not fit the linear relationship observed in tree structures. Thus, Option B is correct.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir