GATE Computer ScienceVery hardGATE CS (PYQ pattern)
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 does not apply.)
- A. Θ(n log log n)
- B. Θ(n log n)
- C. Θ(n)
- D. Θ(n log² n)
Correct answer: A. Θ(n log log n)
Level i of the recursion tree costs 2^i·(n/2^i)/log(n/2^i) = n/(log n − i). Summing over i = 0…log n − 1 gives n·H(log n) = Θ(n log log n); the extra 1/log n in f(n) shrinks the n log n answer by a log factor, not to Θ(n).
More Algorithms questions
- 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?
- Top-down merge sort splits n elements into a left part of ⌈n/2⌉ and a right part of ⌊n/2⌋, and its merge stops comparing as soon as one…