Computer Sciences > GATE 2026 SET-2 > Algorithms
Which of the following can be recurrence relation(s) corresponding to an algorithm with time complexity Θ(n)?
A
T(n) = T(n-1) + 1, T(1) = 1
B
T(n) = 2T(n/2) + 1, T(1) = 1
C
T(n) = 2T(n/2) + n, T(1) = 1
D
T(n) = T(n-1) + n, T(1) = 1

Correct : a,b

To find the time complexity of Θ(n), we need to solve each recurrence relation to see which ones evaluate to linear time.

Option A: T(n) = T(n-1) + 1
Using the substitution method:
T(n) = T(n-2) + 1 + 1 = T(n-2) + 2
Continuing this k times gives us: T(n) = T(n-k) + k.
When we reach the base case T(1), we set n-k = 1, which means k = n-1.
Substituting k back into the equation: T(n) = T(1) + (n-1) = 1 + n - 1 = n.
Therefore, the time complexity is Θ(n). This is correct. ✓

Option B: T(n) = 2T(n/2) + 1
We can solve this using the Master Theorem for divide-and-conquer recurrences of the form T(n) = aT(n/b) + f(n).
Here, a = 2, b = 2, and f(n) = 1.
First, we calculate nlogba = nlog22 = n1 = n.
Now we compare f(n) with n. Since f(n) = 1 is polynomially smaller than n, this falls strictly under Case 1 of the Master Theorem.
Therefore, the time complexity is bounded by nlogba, which gives us Θ(n). This is also correct. ✓

Option C: T(n) = 2T(n/2) + n
Using the Master Theorem again:
Here, a = 2, b = 2, and f(n) = n.
Comparing f(n) with nlogba = n1 = n.
Since f(n) and nlogba are exactly equal, this falls under Case 2 of the Master Theorem. We must multiply by log n.
The time complexity is Θ(n log n). This is incorrect. ✗

Option D: T(n) = T(n-1) + n
Using the substitution method again:
T(n) = T(n-2) + (n-1) + n
If we continue this down to the base case, we get the sum of the first n integers:
T(n) = T(1) + 2 + 3 + ... + n
The sum of the first n integers is n(n+1)/2. Expanding this gives n2/2 + n/2, where the highest order term is n2.
The time complexity is Θ(n2). This is incorrect. ✗

Correct Answer: A and B ✓

Similar Questions

Match the following (P) Prim’s algorithm for minimum spanning tree (i) Backtracking (Q) Floyd-Warshall algorithm fo...
#82 MCQ
Consider the following table Algorithms Design Paradigms (P) Kruskal (i) Divide and Conquer...
#203 MCQ
Consider functions Function 1 and Function 2 expressed in pseudocode as follows: Let f1(n) and f2(n) denote the number of times the statement "x = x + 1" is...
#989 MSQ

Related Topics

recurrence relation time complexity GATE CS 2026 Set-2 Q25 theta n time complexity Master Theorem GATE questions algorithm analysis GATE 2026 divide and conquer recurrence substitution method algorithms computer science GATE previous year questions

Unique Visitor Count

Total Unique Visitors

Loading......