GATE CS 1990 · Arrays & Matrix Representation

MSQ · 1 mark · Problem PROG-DSTR-0275

The total external path length, EPL, of a binary tree with \(n\) external nodes is \(\sum_{w} l_w\), where \(l_w\) is the path length of external node \(w\). Then EPL is (more than one may be correct)
  1. A
    \(\le n^{2}\) always.
  2. B
    \(\ge n\log_{2} n\) always.
  3. C
    equal to \(n^{2}\) always.
  4. D
    \(O(n)\) for some special trees.

Solve it on GATE DA practice →More Basic Data Structures problems

Show the worked solutionEvery internal node has two children, so there are \(n-1\) internal nodes and \(\sum_w 2^{-l_w}=1\).(A) True. The largest EPL comes from a skewed tree, with leaves at depths \(1,2,\ldots,n-1\) and one more at \(n-1\): \(\dfrac{(n-1)(n+2)}{2}\le n^{2}\).(B) True. \(\sum_w 2^{-l_w}=1\) and Jensen's inequality give \(\dfrac{1}{n}\sum_w l_w\ge\log_2 n\), so \(\text{EPL}\ge n\log_2 n\) (equality for a perfect tree).(C) False: the skewed tree has EPL below \(n^{2}\), and a balanced one far below.(D) False: by (B), EPL is \(\Omega(n\log n)\) for every tree.The key published with this item gave only B; A is also always true.Answer: A, B

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com