The GATE Grind

GATE 2015 CS (CS3) – Question 21

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

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

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: 199

Explanation

For any nonempty binary tree, let n₀,n₁,n₂ count zero-,one-,two-child nodes. The edge count gives n₁+2n₂=n₀+n₁+n₂−1, hence n₂=n₀−1. With two hundred leaves this is one hundred ninety-nine.

More Trees and Binary Search Trees questions

All Trees and Binary Search Trees questions →