The number of elements that can be sorted in Θ(logn) time using heap sort is
View worked solutionShowHide
Answer: C
The time complexity of heap sorting k elements is Θ(klogk).
We are given that the total time taken to sort these elements is Θ(logn). Therefore, we need to find the relation for k in terms of n such that:
klogk=Θ(logn)
Let's evaluate the options to find which value of k satisfies this equation:
Option A: If k=Θ(1), then klogk=Θ(1)=Θ(logn).
Option B: If k=Θ(logn), then:
klogk=lognlog(logn)=21lognloglogn=Θ(logn)
Option C: If k=Θ(loglognlogn), then taking the logarithm of k gives:
logk=log(loglognlogn)=loglogn−logloglogn≈loglogn
Now, computing klogk:
klogk≈(loglognlogn)⋅loglogn=logn
Thus, klogk=Θ(logn). This option satisfies the condition.
Option D: If k=Θ(logn), then klogk=Θ(lognloglogn)=Θ(logn).
Hence, the number of elements that can be sorted is Θ(loglognlogn).
Free practice · Your answers on this page are not saved.