Arrange the following recurrence relations in increasing order of their time…
2024
Arrange the following recurrence relations in increasing order of their time capacity.
(A) T(n) = T(n/2) + 1
(B) T(n) = 2T(n/2) + n
(C) T(n) = 3T(n/3) + n
(D) T(n) = 2T(n/2) + n
(E) T(n) = T(n-1) + 1
Choose the correct answer from the options given below :
- A.
(E), (A), (B), (D), (C)
- B.
(A), (E), (D), (B), (C)
- C.
(E), (A), (D), (B), (C)
- D.
(A), (B), (D), (E), (C)
Attempted by 125 students.
Show answer & explanation
Correct answer: B
Compute time complexity for each recurrence:
T(n) = T(n/2) + 1 → Θ(log n). Reason: a = 1, b = 2 ⇒ n^{log_b a} = 1, f(n) = Θ(1), so T(n) = Θ(log n).
T(n) = T(n-1) + 1 → Θ(n). Reason: this recurrence adds 1 for each decrement, summing to Θ(n).
T(n) = 2T(n/2) + n → Θ(n log n). Reason: a = 2, b = 2 ⇒ n^{log_b a} = n, f(n) = Θ(n), so T(n) = Θ(n log n).
T(n) = 3T(n/3) + n → Θ(n log n). Reason: a = 3, b = 3 ⇒ n^{log_b a} = n, f(n) = Θ(n), so T(n) = Θ(n log n).
Order from smallest to largest growth:
T(n) = T(n/2) + 1 — Θ(log n)
T(n) = T(n-1) + 1 — Θ(n)
T(n) = 2T(n/2) + n — Θ(n log n)
T(n) = 2T(n/2) + n — Θ(n log n) (same asymptotic as previous)
T(n) = 3T(n/3) + n — Θ(n log n) (same asymptotic class)
Thus the increasing order by time growth is: T(n) = T(n/2) + 1, then T(n) = T(n-1) + 1, followed by the three Θ(n log n) recurrences. Any permutation of the Θ(n log n) recurrences is asymptotically equivalent.
A video solution is available for this question — log in and enroll to watch it.