The GATE Grind

GATE 2015 CS (CS2) – Question 23

Programming and Data Structures · Trees and Binary Search Trees · 1 mark · Numerical answer

A binary tree T has 20 leaves. How many nodes have exactly two children?

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: 19

Explanation

Let n₀,n₁,n₂ be counts of nodes with zero,one,two children. Counting edges gives n₁+2n₂=n₀+n₁+n₂−1. Therefore n₂=n₀−1=19, regardless of the number of one-child nodes.

More Trees and Binary Search Trees questions

All Trees and Binary Search Trees questions →