Skip to content

ISRO Scientist/Engineer CSE 2020Data Structures › Binary Trees and Binary Search Trees

ISRO Scientist/Engineer CSE 2020 PYQ: Of the following, which best approximates the ratio of the number of nonterminal nodes in the total number…

Of the following, which best approximates the ratio of the number of nonterminal nodes in the total number of nodes in a complete $K$-ary tree of depth $N$ ?

  1. A
    $1/N$
  2. B
    $N-1/N$
  3. C
    $1/K$
    Correct answer
  4. D
    $K-1/K$

Answer

(C) $1/K$

Approach

In a complete K-ary tree of depth N (assuming the standard perfect-tree definition where all leaves are at the same depth), the total number of nodes is $(K^{N+1}-1)/(K-1) \text{and the number of nonterminal nodes is} (K^N-1)/(K-1). \text{Their ratio is} (K^N-1)/(K^{N+1}-1), \text{which for large} N \text{tends to} 1/K. \text{Even if depth is counted as number of levels, the ratio becomes} (K^{N-1}-1)/(K^N-1), \text{still approximating} 1/K. \text{Thus option} C$ is the best approximation.

Reviewed by ISRO IQ Editorial Team.