Question

Consider the following recurrence relation.

T(n)={T(n/2)+T(2n/5)+7nif n>01if n=0T(n) = \begin{cases} T(n/2) + T(2n/5) + 7n & \text{if } n > 0 \\ 1 & \text{if } n = 0 \end{cases}

Which one of the following options is correct?

Choose one option
Official answer and solution
Official answer
C
From
Official GATE 2021 answer key

Solution

Apply the recursion tree method or the Akra-Bazzi method to determine the asymptotic complexity of the divide-and-conquer recurrence.

The given recurrence is T(n)=T(n/2)+T(2n/5)+7nT(n) = T(n/2) + T(2n/5) + 7n for n>0n > 0, with base case T(0)=1T(0) = 1.

Let us examine the total non-recursive work performed at each level of the recursion tree:

  • Level 0 (root): 7n7n
  • Level 1: 7(n/2)+7(2n/5)=7n(12+25)=7n(910)7(n/2) + 7(2n/5) = 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

Because the branch sum factor 12+25=910<1\frac{1}{2} + \frac{2}{5} = \frac{9}{10} < 1, the work per level forms a strictly decreasing geometric series dominated by the root level:

T(n)=∑k=0∞7n(910)k=7n×11−9/10=70n=Θ(n)T(n) = \sum_{k=0}^{\infty} 7n \left(\frac{9}{10}\right)^k = 7n \times \frac{1}{1 - 9/10} = 70n = \Theta(n)

Alternatively, applying the Akra-Bazzi theorem, pp is the solution to (1/2)p+(2/5)p=1(1/2)^p + (2/5)^p = 1. Since (1/2)1+(2/5)1=9/10<1(1/2)^1 + (2/5)^1 = 9/10 < 1, p<1p < 1. Because g(n)=7n=Θ(n1)g(n) = 7n = \Theta(n^1) grows strictly faster than npn^p, T(n)=Θ(n)T(n) = \Theta(n).

Hence, T(n)=Θ(n)T(n) = \Theta(n), matching option C.

Final answer

C

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2021 Computer Science and Information Technology (CS, Set-1)
Question
40 of 65, printed as CS Q.30
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.