GATE Computer ScienceVery hardGATE CS (PYQ pattern)
The running time satisfies T(n) = T(n/2) + T(n/3) + T(n/6) + n. Which bound is tight?
- A. Θ(n)
- B. Θ(n^(log₂3))
- C. Θ(n²)
- D. Θ(n log n)
Correct answer: D. Θ(n log n)
The fractions 1/2 + 1/3 + 1/6 sum to exactly 1, so every level of the tree costs n and the depth is Θ(log n) (the shortest path is log₆ n, the longest log₂ n). Dropping T(n/6) would give Θ(n).
More Algorithms questions
- 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]…
- A recursive matrix-chain function without memoisation, cost(i, j), returns 0 when i = j and otherwise calls cost(i, k) and cost(k+1, j)…