• recategorized by
1,327 views
2 2 votes

What is the time complexity of finding the kth smallest element in an array?

  1. $O(\log n)$
  2. $o(\log n)$
  3. $\Omega(n\log n)$
  4. $O(n)$

1 Answer

1 1 vote
Build Min heap O(n)

Delete min elements upto k times = k * O(log n)

Insert all k elements back k * O(log n)

Dominating term O(n) so (D) is the answer.

Since Omega() will be the lower bound, but here in worst case k = n, so O(n logn) should be given for n logn to be a correct answer.
Answer:
Position:
Show:

Related questions

1 1 vote
0 0 answers
3.2k
3.2k views
srestha asked Mar 15, 2017
3,206 views
Lets say we have a 32bit instruction using immediate addressing mode, where the opcode is say 22bits, and u have to store a 32bit operand inside the remaining 10bits of t...
3 3 votes
1 1 answer
2.5k
2.5k views
admin asked Apr 2, 2020
2,523 views
Consider the process of inserting an element into a $Max\ Heap$, where the $Max\ Heap$ is represented by an $array$. Suppose we perform a binary search on the path from ...
3 3 votes
1 1 answer
227
227 views
Shubham Sharma 2 asked Jul 24, 2025
227 views
Which of the following operations can be performed in $\mathrm{O}(\log n)$ time in a binary heap?Deleting the root elementInserting an elementBoth $\text{(A)}$ and $\text...