Skip to content
Official PYQ · 1990

GATE CS 1990 Q3-iv — Trees

Explain with AI

The total external path length, EPL,\text{EPL}, of a binary tree with nn external nodes is, EPL=∑wIw\text{EPL}= \displaystyle \sum_{w} I_w, where IwI_{w} is the path length of external node ww),

Choose one option
View worked solution

Answer: B

The total external path length (EPL\text{EPL}) of a binary tree with nn external nodes is the sum of the depths of all nn external nodes. Let did_i denote the depth of the ii-th external node for 1≤i≤n1 \le i \le n. Thus, EPL=∑i=1ndi\text{EPL} = \sum_{i=1}^{n} d_i.

By Kraft's Inequality for any binary tree, the depths of the external nodes must satisfy:

∑i=1n2−di≤1\sum_{i=1}^{n} 2^{-d_i} \le 1

Using the properties of entropy or Gibbs' inequality, we can find the minimum value of ∑di\sum d_i. Let pi=1np_i = \frac{1}{n} for all ii. Then:

∑i=1npilog⁡2(pi2−di)≥0  ⟹  ∑i=1n1n(di−log⁡2n)≥0\sum_{i=1}^{n} p_i \log_2\left(\frac{p_i}{2^{-d_i}}\right) \ge 0 \implies \sum_{i=1}^{n} \frac{1}{n} \left(d_i - \log_2 n\right) \ge 0 1n∑i=1ndi≥log⁡2n  ⟹  EPL≥nlog⁡2n\frac{1}{n} \sum_{i=1}^{n} d_i \ge \log_2 n \implies \text{EPL} \ge n \log_2 n

This lower bound is achieved when the binary tree is perfectly balanced, where each external node has a depth of approximately log⁡2n\log_2 n. Therefore, EPL≥nlog⁡2n\text{EPL} \ge n \log_2 n always holds.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Trees questions