GATE Computer ScienceHardGATE CS (PYQ pattern)
Let T(1) = 1 and T(n) = (1 + 1/n)·T(n − 1) + 1 for n ≥ 2. Which is the tight bound on T(n)?
- A. Θ(n log n)
- B. Θ(log n)
- C. Θ(n)
- D. Θ(n log² n)
Correct answer: A. Θ(n log n)
Divide by n + 1: T(n)/(n+1) = T(n−1)/n + 1/(n+1). So U(n) = T(n)/(n+1) = 1/2 + Σ_{k=3}^{n+1} 1/k = Θ(log n), giving T(n) = Θ(n log n). Treating the factor (1 + 1/n) as 1 gives Θ(n).
More Algorithms questions
- The running time satisfies T(n) = T(n/2) + T(n/3) + T(n/6) + n. Which bound is tight?
- Solve T(n) = √n·T(√n) + n·log₂ n for n = 2^(2^k), with T(2) = 2. Which is the tight bound?
- The maximum and the minimum of n numbers are found by divide and conquer: a list of 1 element needs 0 comparisons, 2 elements need 1; a…
- The strings X = XYXZYXZ and Y = YZXYXZY are given. Their longest common subsequences all have length 5. How many distinct strings of…
- The edit distance between PNEUMONIA and AMMONIA is computed with insertion, deletion and substitution each costing 1. What is the minimum…
- Matrices A₁ … A₇ have dimensions 5×12, 12×7, 7×20, 20×4, 4×15, 15×9 and 9×6, i.e. the dimension array p = [5, 12, 7, 20, 4, 15, 9, 6]…