GATE / CS ARCHIVE

GATE CSE 1997 / QUESTION 16(a)

Bound size-balanced tree size

Data Structures · Binary Search & Balanced Trees · Full GATE CSE 1997 paper

GATE 1997, Q16(a) 3 marks · Descriptive
Report issue

Binary Search & Balanced Trees

Question 16(a), GATE 1997: A size-balanced binary tree has, at every node, left and right subtree sizes differing by at most one. Node distance is the number of edges from the root, and tree height h is the greatest root-to-leaf distance. Prove by induction on h that a tree of height h has at least 2^h nodes.
Question 16(a), GATE 1997: A size-balanced binary tree has, at every node, left and right subtree sizes differing by at most one. Node distance is the number of edges from the root, and tree height h is the greatest root-to-leaf distance. Prove by induction on h that a tree of height h has at least 2^h nodes.
Tap to enlarge
Answer & solution

Answer: Every such tree has N≥2^h; the bound is attainable. (no official key was published)

Use induction on the nonnegative height h. For h=0 the tree consists of the root, so N=1=20.

For h≥1, at least one child subtree has height h−1; otherwise no root-to-leaf path could have length h. Call that subtree T and let its size be s. By the induction hypothesis, s≥2h−1. The other child subtree has size t≥s−1, because the defining balance condition bounds the size difference by one. Empty subtrees are allowed and have size zero, so this also handles h=1.

Counting the root gives

N=1+s+t ≥1+s+(s−1)=2s ≥2h.

This proves the assertion. We did not assume the two subtrees have equal height or that every level is full. Size balance is a statement about node counts, and the proof uses exactly that statement.

The bound is sharp. For h≥1, combine a minimum-size tree of height h−1, with 2h−1 nodes, and a perfect tree of height h−2, with 2h−1−1 nodes, below a new root. Their sizes differ by one and their subtrees satisfy the same condition. The total is 2h and the height is h. At h=1 the smaller subtree is empty. This construction also explains why the stronger bound 2h+1−1 would be false: a size-balanced tree need not be perfect at its last level.

Original paper, page 8