Skip to content
Official PYQ · 2013

GATE CS 2013 Q30 — Searching, Sorting, Hashing

Explain with AI

The number of elements that can be sorted in Θ(log⁡n)\Theta(\log n) time using heap sort is

Choose one option
View worked solution

Answer: C

The time complexity of heap sorting kk elements is Θ(klog⁡k)\Theta(k \log k).

We are given that the total time taken to sort these elements is Θ(log⁡n)\Theta(\log n). Therefore, we need to find the relation for kk in terms of nn such that:

klog⁡k=Θ(log⁡n)k \log k = \Theta(\log n)

Let's evaluate the options to find which value of kk satisfies this equation:

  • Option A: If k=Θ(1)k = \Theta(1), then klog⁡k=Θ(1)≠Θ(log⁡n)k \log k = \Theta(1) \neq \Theta(\log n).
  • Option B: If k=Θ(log⁡n)k = \Theta(\sqrt{\log n}), then: klog⁡k=log⁡nlog⁡(log⁡n)=12log⁡nlog⁡log⁡n≠Θ(log⁡n)k \log k = \sqrt{\log n} \log(\sqrt{\log n}) = \frac{1}{2} \sqrt{\log n} \log \log n \neq \Theta(\log n)
  • Option C: If k=Θ(log⁡nlog⁡log⁡n)k = \Theta\left(\frac{\log n}{\log \log n}\right), then taking the logarithm of kk gives: log⁡k=log⁡(log⁡nlog⁡log⁡n)=log⁡log⁡n−log⁡log⁡log⁡n≈log⁡log⁡n\log k = \log\left(\frac{\log n}{\log \log n}\right) = \log \log n - \log \log \log n \approx \log \log n Now, computing klog⁡kk \log k: klog⁡k≈(log⁡nlog⁡log⁡n)⋅log⁡log⁡n=log⁡nk \log k \approx \left(\frac{\log n}{\log \log n}\right) \cdot \log \log n = \log n Thus, klog⁡k=Θ(log⁡n)k \log k = \Theta(\log n). This option satisfies the condition.
  • Option D: If k=Θ(log⁡n)k = \Theta(\log n), then klog⁡k=Θ(log⁡nlog⁡log⁡n)≠Θ(log⁡n)k \log k = \Theta(\log n \log \log n) \neq \Theta(\log n).

Hence, the number of elements that can be sorted is Θ(log⁡nlog⁡log⁡n)\Theta\left(\frac{\log n}{\log \log n}\right).

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Searching, Sorting, Hashing questions