GATE Computer ScienceVery hardGATE CSE · UGC NET
What is the minimum number of comparisons needed in the worst case to find the SECOND smallest of 100 distinct elements?
- A. 101
- B. 106
- C. 105
- D. 198
Correct answer: C. 105
n + ⌈log₂ n⌉ − 2 = 100 + 7 − 2 = 105 using a knockout tournament and then comparing the ⌈log₂ n⌉ elements that lost directly to the winner.
More Algorithms questions
- Consider T(n) = 2T(n/2) + n/log₂n for n ≥ 2 (n a power of 2, T(1) = 1). Which is the tightest bound? (The Master theorem in its basic form…
- Let T(n) = 2T(√n) + log₂ n for n > 2, with T(2) = 1, where n is always of the form 2^(2^k). What is the exact value of T(2^16)?
- Consider T(n) = 2T(n/2) + 8T(n/4) + n² with T(1) = 1 (the subproblem sizes add up to 3n, not n). Which is the tight bound?
- Let T(n) = 2T(n/2) + n·log₂ n for n ≥ 2, T(1) = 1, with n = 2^k. Which is the exact closed form of T(n)?
- An adversarial quicksort always splits an input of size n into parts of sizes n/10 and 9n/10, so T(n) = T(n/10) + T(9n/10) + n. For large…
- What is the minimum number of comparisons that guarantees finding the second largest of 1025 distinct numbers in the worst case?