GATE / CS ARCHIVE

SIMILAR QUESTIONS / ALGORITHMS

Solve fixed-ratio recurrences by comparing the nonrecursive cost

7 questions solved the same way, newest first. Back to Algorithms

How these are solved

Each requires extracting a,b and the nonrecursive cost in T(n)=aT(n/b)+f(n), comparing f with n^(log_b a), and obtaining the asymptotic order. The values and dominating cases differ.

1 mark · MCQ
Report issue

Solving nested recurrences

Asymptotic Analysis & Recurrences

Question 17, GATE 2026: For n>1, T1(n)=4T1(n/2)+T2(n), and T2(n)=5T2(n/4)+Θ(log₂n). Both equal 1 for n≤1. Determine T1’s asymptotic order among n², n²log₂n, n^(log₄5), and n^(log₄5)log₂n.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Our answer: Theta(n^2)

Givens and goal

For n>1, T1(n)=4T1(n/2)+T2(n), and T2(n)=5T2(n/4)+Θ(log₂n). Both equal 1 for n≤1. Determine T1’s asymptotic order among n², n²log₂n, nlog₄5, and nlog₄5log₂n.

Approach

Solve T2 first, then use its growth rate as the nonrecursive term in the recurrence for T1.

Step-by-step solution

1. In T2, the branching parameters are a=5 and b=4. The critical power is nlog₄5. Set α=log₄5≈1.161.
2. A logarithm is polynomially smaller than n^α: for example log₂n=O(nα/2). The first case of the Master theorem therefore gives T2(n)=Θ(n^α).
3. Substitute into T1: T1(n)=4T1(n/2)+Θ(n^α). Its critical power is nlog₂4=n². Because α<2, the additive term is again polynomially smaller than the critical power.
4. Applying the same Master-theorem case yields T1(n)=Θ(n²), option A. There is no extra logarithmic factor because the additive term is not Θ(n²), which would be the balanced case.
5. A recursion-tree check explains the dominance. At depth j, the T2 work totals Θ(4j(n/2j)^α)=Θ(n^α(4/2^α)j). The ratio exceeds 1, so lower levels dominate. With depth log₂n, the leaf scale is 4log₂n=n². Standard floor/ceiling handling of non-power inputs does not change this asymptotic result.

Original paper, page 14 · Answer key

2 marks · NAT
Report issue

Asymptotic Analysis & Recurrences

Question 39, GATE 2016: A recursive flowchart starts with A(n/2), then branches. Left: call A(n/2), return. Right: call A(n/2) twice, then branch to return or call A(n/2) and branch again to return or one final A(n/2) then return. All other work is O(1); assume a constant-size base case and attainable recursive worst branches. Find the least α for worst-case O(n^α), to two decimals.
Tap to enlarge
Answer & solution

Official answer: 2.2 : 2.4

Our answer: log₂5 ≈2.32

Assuming the displayed worst branch can recur and a constant-size base case, T(n)=5T(n/2)+O(1), yielding Theta(nlog₂5). The least exponent islog₂5≈2.32; the official accepted interval 2.2 : 2.4 is preserved.

Only calls on a single executed control-flow path are added. The two alternative exits must not both be counted. At recursion level j, the worst-case tree has 5j calls of size n/2j; after log₂n levels it has 5log₂n=nlog₂5 leaves. This yields the exponent without mistaking five sequential calls for five levels of recursion.

Original paper, page 36 · Answer key

1 mark · MCQ
Report issue

Asymptotic Analysis & Recurrences

Question 13, GATE 2014: Solve asymptotically T(n)=2T(n/2)+log n with T(1)=1. A Θ(n); B Θ(n log n); C Θ(n²); D Θ(log n).
Tap to enlarge
Your answer
Answer & solution

Official answer: A

1. Set up the reasoning. Apply the Master theorem with a=2 and b=2: nlogb a=n. The extra work log n grows polynomially more slowly than n, for example log n=O(n1/2).

2. Derive the result. For T(n)=2T(n/2)+log n, the leaf contribution is n. At level i, extra cost is 2i(log₂n−i); its total over levels is O(n). Equivalently log n is polynomially smaller than n in the Master theorem. Therefore T(n)=Θ(n), A.

3. Check the interpretation. There are n constant-cost leaves, which already force an Ω(n) lower bound. The logarithmic work is not multiplied by n at every level; subproblem sizes shrink, and summing the level costs gives O(n).

Original paper, page 32 · Answer key

2 marks · MCQ
Report issue

Geometric-sum recurrence

Asymptotic Analysis & Recurrences

Question 35, GATE 2009: T(n)=n for n≤3, otherwise T(n)=T(n/3)+cn with fixed c>0. Which growth rate? A Θ(n); B Θ(n log n); C Θ(n²); D Θ(n² log n).
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Expanding T(n)=T(n/3)+cn gives cn+cn/3+cn/9+... plus a constant-size base case. For fixed positive c this is bounded above by(3c/2)n+O(1) and below by cn. Hence Θ(n), A, with routine integer rounding not changing the asymptotic result.

The recursion tree has only one child, whose size shrinks by 3. Work by level is cn, cn/3, cn/9, … . The geometric sum is below cn/(1−1/3)=1.5cn, while the root alone contributes cn. These upper and lower linear bounds establish Θ(n). The depth is logarithmic, but multiplying n by that depth overcounts because work per level decreases rather than remaining n.

Original paper, page 8

2 marks · MCQ
Report issue

False bound for a divide-and-conquer recurrence

Asymptotic Analysis & Recurrences

Question 37, GATE 2005: T(n)=2T(n/2)+n, with T(0)=T(1)=1. Which claim is false? A O(n²); B Θ(n log n); C Ω(n²); D O(n log n).
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

For n=2k, dividing by n gives T(n)/n=T(n/2)/(n/2)+1, so T(n)=n(1+log2 n). Standard rounding of subproblem sizes preserves Θ(n log n). Therefore O(n²), Θ(n log n), and O(n log n) hold, but Ω(n²) does not, C, since(n log n)/n²→0.

For powers of two, each recursion level contributes n and there are log₂n nontrivial levels plus linear total base cost. Thus T(n)=n(1+log₂n), giving Θ(n log n). This is bounded above by n² but not below by a positive constant times n², since log n/n tends to zero. Hence the false bound is C. A loose upper bound can still be true even when it is not tight.

Original paper, page 5

2 marks · MCQ
Report issue

Recurrence dominated by leaf work

Asymptotic Analysis & Recurrences

Question 4.6, GATE 1997: T(1)=1 and T(n)=2T(floor (n/2))+sqrt (n) for n≥2. Choose O(sqrt n), O(n), O(log n), none.
Tap to enlarge
Your answer
Answer & solution

Answer: B: Θ(n) (no official key was published)

At recursion depth j there are roughly 2j subproblems of size n/2j. Their combined nonrecursive work is sqrt (n)·2j/2, increasing geometrically toward the leaves. Summing through depth about log 2 n gives O(n), and there are Θ(n) leaves each contributing constant work, providing Ω(n). Hence T(n)=Θ(n), so B. Equivalently the Master theorem has nlog 2 2=n and toll n1/2, which is polynomially smaller; rounding does not change the asymptotic order.

Original paper, page 4

2 marks · MCQ
Report issue

A divide-and-conquer recurrence

Asymptotic Analysis & Recurrences

Question 2.12, GATE 1996: Solve T(1)=2, T(n)=3T(n/4)+n asymptotically for powers of four.
Question 2.12, GATE 1996: Solve T(1)=2, T(n)=3T(n/4)+n asymptotically for powers of four.
Tap to enlarge
Your answer
Answer & solution

Answer: A: Θ(n) (no official key was published)

At recursion depth j there are 3j subproblems of size n/4j, so the total nonrecursive work is n(3/4)j. Summing these decreasing geometric terms gives O(n), while the root alone costs n and proves Ω(n). More exactly, with k=log₄ n, the leaves contribute 2·3k and internal levels contribute 4n(1−(3/4)k). The total is 4n−2nlog₄3. Therefore the recurrence is linear, not n log n, because each successive level contributes less work than the preceding one.

Original paper, page 5