21,074 views
46 46 votes

The solution to the recurrence equation $T(2^k) = 3T(2^{k-1})+1, T(1) =1$ is

  1. $2^k$
  2. $\frac{(3^{k+1}-1)}{2}$
  3. $3^{\log_2 k}$
  4. $2^{\log_3 k}$

5 Answers

Best answer
117 117 votes

Let $x = 2^k$
$T(x) = 3T\left(\frac{x}{2}\right) + 1$
We can apply Master's theorem case 1 with $a = 3$ and $b = 2$ as $f(x) = 1 = O\left(x^{\log_2 3 - \epsilon} \right), \epsilon > 0 $

So, $T(x) = \Theta \left(x^{\log_2 3}\right)  \\= \Theta \left( {2^k}^{\log_2 3} \right)\\= \Theta \left({2^{\log_2 3}}^k \right)\\ = \Theta \left(3^k \right)$

So, only option possible is B.



We can also directly solve as follows:

$T(x) = 3T\left(\frac{x}{2}\right) + 1$
$\\\quad= 9T \left (\frac{x}{4}\right) + 1 + 3$
$ \\\quad \vdots$
$ \\\quad= 3^{\log_2 2^k} + \left( 1 + 3 + 9 + \dots + 3^{\log_2 {2^k-1}}\right)$
$\\\quad \left(\text{recursion depth is }\log_2 x \text{ and } x = 2^k\right)$
$ \\\quad= 3^{k} + \frac{3^{\log_2 {2^k}} - 1}{3-1}$
$ \\\quad \left(\text{Sum to n terms of GP with } a = 1 \text{ and } r = 3 \right)$
$\\\quad =3^k + \frac{3^k - 1}{2}$
$\\\quad=\frac{3. 3^k - 1}{2}$
$\\\quad=\frac{3^{k+1} -1}{2} $



OR
 
$T\left(2^k\right) = 3T\left(2^{k-1}\right) + 1$
$ \\\quad= 3^2T\left(2^{k-2}\right) + 1 +3$
$ \quad\vdots$
$ \\\quad= 3^k T\left(2^{k-k}\right) + \left( 1 + 3 + 9 + \dots + 3^{k-1}\right)$
$ \\\quad \left(\text{recursion depth is }k\right)$
$\\\quad= 3^k + \frac{3^{k -1}} {3-1}$
$\\\quad\left(\text{Sum to n terms of GP with } a = 1 \text{ and } r = 3 \right)$
$\\\quad=3^k + \frac{3^k -1}{2}$
$\\\quad=\frac{3. 3^k - 1}{2}$
$\\=\frac{3^{k+1} -1}{2}  $

• edited by
6 6 votes
As other than the recursion function , any function of K is not added , this equation is equivalent to  T(k) = 3T(k-1) + 1  , T(0) = 1

Using repeated substitution we can observe that    T(k) = 1 + 3^1 + 3^2 ... + 3^k .

Using geometric series summation   T(n)  = (3^(k+1) - 1)/2
2 2 votes

Solving by Substitution-

$T(2^k)=3T(2^{k-1})+1$

           $=3[3T(2^{k-2})+1]+1$

           $=3^2T(2^{k-2})+3+1$

           .

           .

           .

          $=3^xT(2^{k-x})+3^{x-1}+3^{x-2}+3^{x-3}.......+3^2+3^1+3^0$

now base condition is $T(1)=1$,

Therefore, $T(2^0)=1$ and we have $T(2^{k-x})$
Thus, comparing the powers, we get


$k-x=0$


$k=x$

Substituting it again in the recurrence we get-


          $=3^k+3^{k-1}+3^{k-2}.......+3^2+3^1+3^0$


Now this is GP. Common ratio = 3, first term =1, total terms =k+1


Thus, $\frac{3^{k+1}-1}{2}$ --ANSWER.

Answer:
Position:
Show:

Related questions

59 59 votes
7 answers 7 answers
25.8k
25.8k views
Kathleen asked Sep 15, 2014
25,795 views
The running time of the following algorithmProcedure $A(n)$If $n \leqslant 2$ return ($1$) else return $(A( \lceil \sqrt{n} \rceil))$;is best described by$O(n)$$O(\log ...
32 32 votes
3 answers 3 answers
10.3k
10.3k views
Kathleen asked Sep 15, 2014
10,283 views
Fill in the blanks in the following template of an algorithm to compute all pairs shortest path lengths in a directed graph $G$ with $n*n$ adjacency matrix $A$. $A[i,j]$ ...
23 23 votes
5 answers 5 answers
7.8k
7.8k views
Kathleen asked Sep 15, 2014
7,785 views
Let $A$ be a set of $n(>0)$ elements. Let $N_r$ be the number of binary relations on $A$ and let $N_f$ be the number of functions from $A$ to $A$Give the expression for $...
38 38 votes
4 answers 4 answers
12.5k
12.5k views
Kathleen asked Sep 15, 2014
12,478 views
Let $f(A,B) = A'+B$. Simplified expression for function $f(f(x+y, y), z)$ is$x' + z$$xyz$$xy' + z$None of the above