UGC-NET Jun 2013 · Trees

MCQ · 2 marks · Problem PROG-DSTR-0021

In any \(n\)-element heap, which of the following is the tightest correct statement about the number of nodes of height \(h\)?
  1. A
    less than or equal to \(\left\lceil \dfrac{n}{2^{h}} \right\rceil\)
  2. B
    greater than \(\left\lceil \dfrac{n}{2^{h}} \right\rceil\)
  3. C
    greater than \(\left\lceil \dfrac{n}{2^{h+1}} \right\rceil\)
  4. D
    less than or equal to \(\left\lceil \dfrac{n}{2^{h+1}} \right\rceil\)

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

Show the worked solution\[\boxed{\#\{\text{nodes of height } h\}\le\left\lceil \frac{n}{2^{h+1}}\right\rceil}\]The leaves (\(h=0\)) number exactly \(\lceil n/2\rceil\), so the bound is reached, and moving up one height at most halves the count.(A) is also true but twice as loose, so it is not the tightest.(B) and (C) are false: for \(h=0\) the count equals \(\lceil n/2\rceil\), which is not greater than either bound.Answer: D

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