The GATE Grind

GATE 2013 CS (CS1) – Question 40

Algorithms · Asymptotic Analysis and Time/Space Complexity · 2 marks · Multiple choice

How many elements can heap sort sort in $\Theta(\log n)$ time?

  1. $\Theta(1)$
  2. $\Theta(\sqrt{\log n})$
  3. $\Theta(\log n/\log\log n)$
  4. $\Theta(\log n)$

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (C) $\Theta(\log n/\log\log n)$

Explanation

Heap sorting m elements takes Θ(m log m). Choose $m=\Theta(\log n/\log\log n)$; then log m=Θ(log log n), and their product is Θ(log n). Thus C. Sorting Θ(log n) elements would add a log log n factor.

More Asymptotic Analysis and Time/Space Complexity questions

All Asymptotic Analysis and Time/Space Complexity questions →