UGC-NET Jun 2014 · Heap Sort & Non-Comparison Sorts

MCQ · 2 marks · Problem PROG-SORT-0005

Suppose that the splits at every level of quicksort are in the proportion $(1 – \alpha)$ to $\alpha$, where $0<\alpha\leq\frac{1}{2}$ is a constant. The minimum depth of a leaf in the recursion tree is approximately given by
  1. A
    $-\frac{lgn}{lg(1-\alpha)}$
  2. B
    $-\frac{lg(1-\alpha)}{lgn}$
  3. C
    $-\frac{lgn}{lg\alpha}$
  4. D
    $-\frac{lg\alpha}{lgn}$

Solve it on GATE DA practice →More Searching & Sorting Algorithms problems

Show the worked solutionThe shortest root-to-leaf path follows the smaller part each time, of relative size \(\alpha\le\frac12\). After \(d\) levels its size is \(n\alpha^d\), which reaches 1 when\[n\alpha^d=1\ \Rightarrow\ d=\log_{1/\alpha}n=\frac{\lg n}{\lg(1/\alpha)}=-\frac{\lg n}{\lg\alpha}.\](Following the larger part \(1-\alpha\) gives the maximum depth \(-\lg n/\lg(1-\alpha)\), option A.)Answer: C

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