GATE Computer Science · Programming, Data Structures, and Algorithms · medium
Consider the recurrence relation T(n) = 4T(n / 2) + n^2 for n > 1, with T(1) = 1. Using the Master Theorem, what is the tight asymptotic bound for T(n)?
Published · Last updated · checked before publication — how we verify questions
Options
Answer: B. Theta(n^2 log n) by Case 2 of the Master Theorem where log_2(4) = 2
For T(n) = 4T(n/2) + n^2, we have a = 4, b = 2 and f(n) = n^2. The critical exponent is log_b(a) = log_2(4) = 2, so the watershed function is n^2. Because f(n) = Theta(n^2) matches n^(log_b a) exactly, Case 2 of the Master Theorem applies and T(n) = Theta(n^(log_b a) * log n) = Theta(n^2 log n). Intuitively, the recursion tree has about log_2 n levels, and at level i there are 4^i subproblems of size n/2^i, each costing (n/2^i)^2, so every level contributes the same n^2 work. Summing n^2 over log n levels gives n^2 log n. The most common trap is to compare f(n) with n^a or with n instead of n^(log_b a), or to assume that a dominant-looking f(n) means the answer is just f(n). When f(n) equals the watershed function, no single level dominates and a log factor appears.
Why the other options are wrong
- A. Theta(n^2) because the driving term f(n) = n^2 dominates the recurrence — Theta(n^2) would be the answer if f(n) polynomially dominated n^(log_b a), as in Case 3 where the root level carries most of the work. Here f(n) is exactly equal to n^2, not larger by a polynomial factor, so all log n levels contribute equally and the log factor cannot be dropped.
- C. Theta(n^4) because the branching factor a = 4 raises the polynomial degree to 4 — Theta(n^4) wrongly uses the branching factor a = 4 as the exponent. The Master Theorem compares f(n) with n^(log_b a) = n^2, not n^a, and the total work cannot exceed n^2 log n here.
- D. Theta(n log n) matching standard divide-and-conquer sorting recurrences — Theta(n log n) is the solution of the mergesort-style recurrence T(n) = 2T(n/2) + n, where a = 2 and log_b a = 1. This recurrence has a = 4 and f(n) = n^2, so the critical exponent is 2 and the bound is larger.
More Programming, Data Structures, and Algorithms questions
- For Quicksort using deterministic last-element pivoting on an array of n distinct elements that is already sorted in…
- What is the length of the Longest Common Subsequence (LCS) of the two strings X = 'ABCBDAB' and Y = 'BDCABA'?
- Which two statements accurately compare Dijkstra's single-source shortest-path algorithm and the Bellman-Ford…
- A message uses five characters A, B, C, D, and E with frequencies 5, 9, 12, 13, and 16 respectively. Using optimal…
All Programming, Data Structures, and Algorithms questions and the topic overview →
GATE is a mark of the Indian Institute of Science and the Indian Institutes of Technology. PrepIQ Hub is not affiliated with, endorsed by, or sponsored by the GATE Committee.