recategorized by
593 views
2 votes
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)$
recategorized by

1 Answer

1 votes
1 votes
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:

Related questions

1 votes
1 votes
0 answers
1
srestha asked Mar 15, 2017
1,395 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...