Skip to content
Official PYQ · 2021

GATE CS 2021 Set 1 Q30 — Asymptotic Worst Case Time and Space Complexity

Explain with AI

Consider the following recurrence relation.

T(n)={T(n∕2)+T(2n∕5)+7nif  n>01if  n=0T\left ( n \right )=\left\{\begin{array} {lcl} T(n ∕ 2)+T(2n∕5)+7n & \text{if} \; n>0\\1 & \text{if}\; n=0 \end{array}\right.

Which one of the following options is correct?

Choose one option
View worked solution

Answer: C

We can solve this recurrence relation using the recursion tree method.

Let us analyze the cost at each level of the recursion tree:

  • Level 0: 7n7n
  • Level 1: 7(n2)+7(2n5)=7n(12+25)=7n(910)7\left(\frac{n}{2}\right) + 7\left(\frac{2n}{5}\right) = 7n\left(\frac{1}{2} + \frac{2}{5}\right) = 7n\left(\frac{9}{10}\right)
  • Level 2: 7n(910)27n\left(\frac{9}{10}\right)^2
  • Level kk: 7n(910)k7n\left(\frac{9}{10}\right)^k

The total cost T(n)T(n) is the sum of the costs at all levels. Since the work at each level decreases geometrically, we can upper-bound the total cost by an infinite geometric series:

T(n)≤∑k=0∞7n(910)k=7n(11−910)=70nT(n) \le \sum_{k=0}^{\infty} 7n \left(\frac{9}{10}\right)^k = 7n \left( \frac{1}{1 - \frac{9}{10}} \right) = 70n

Since the root level alone contributes 7n7n, we also have T(n)≥7nT(n) \ge 7n. Therefore, we get:

7n≤T(n)≤70n  ⟹  T(n)=Θ(n)7n \le T(n) \le 70n \implies T(n) = \Theta(n)

Thus, the correct option is C.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Asymptotic Worst Case Time and Space Complexity questions