UGC-NET Sep 2013 · Heap Sort & Non-Comparison Sorts

MCQ · 2 marks · Problem PROG-SORT-0011

Suppose that the splits at every level of Quicksort are in proportion $1-\beta \text{ to } \beta$, where $0 < \beta \leq 0.5$ is a constant. The number of elements in an array is n. The maximum depth is approximately
  1. A
    0.5 $\beta$ Ig n
  2. B
    0.5 (1-$\beta$) Ig n
  3. C
    -(Ig n)/(Ig $\beta$)
  4. D
    -(Ig n)/Ig (1-$\beta$)

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

Show the worked solutionThe deepest path follows the larger part, of relative size \(1-\beta\ge\frac12\). After \(d\) levels its size is \(n(1-\beta)^d\), which reaches 1 when\[n(1-\beta)^d=1\ \Rightarrow\ d=\frac{\lg n}{\lg\frac{1}{1-\beta}}=-\frac{\lg n}{\lg(1-\beta)}.\]Option C, \(-\lg n/\lg\beta\), is the minimum depth (following the smaller part).Answer: D

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