edited by
1,122 views
3 votes
3 votes

Solve the Following Recurrence using

  • Back Substitution
  • Master Theorem

$T(n)=T(\sqrt{n})+n+c$ 


Using Master Theorem


Using Master Theorem,

put n = $2^{m}$

$ T(n)=T(2^{m})= S(m)$ ie $T(\sqrt{n}) = S(\frac{m}{2})$

Hence the Recurrence Relation will be
$S(m)=S(\frac{m}{2})+ 2^{m}$

Here a =1 , b=2 $f(m)=2^{m}$

case 1 :  $2^{m} \notin O(m^{\log_b a - \epsilon })$

case 2 : $2^{m} \notin \Theta (m^{\log_b a } \log^{k} n)$

case 3 : $2^{m} \in \Omega (m^{\log_b a +\epsilon } )$

put $\epsilon = 1$  We get

$2^{m} \in \Omega (m^{\log_2 1 +1 } ) \Rightarrow \Omega (m^{0+1})\Rightarrow \Omega (m)$ Which is True

Now checking Regularity

$af(\frac{m}{b})\leq \delta f(m) \Rightarrow f(\frac{m}{2})\leq \delta f(m)$

ie .$2^{\frac{m}{2}} \leq \delta \ 2^{m}$ taking log on both sides
$\frac{m}{2}\leq \log_2 \delta +m$

taking $\delta =\frac{1}{2}$

$\frac{m}{2}\leq -1 +m \Rightarrow 1 \leq  \frac{m}{2} $

How to check this last condition is satisfied or not ??

Using Back Substitution

$T(n)=T(\sqrt{n})+n+c$

$T(n)= T(n^{\frac{1}{2}})+n+b \\ = T(n^{\frac{1}{4}})+n^{\frac{1}{2}}+n+2b \\ =T(n^{\frac{1}{8}})+n^{\frac{1}{4}}+n^{\frac{1}{2}}+n+3b \\ ... \\ .. \\ = T(n^{\frac{1}{2^{k}}})+\sum_{i=1}^{k} n^{\frac{1}{2^{i}}} + kb$

How to proceed further... ?

edited by

1 Answer

6 votes
6 votes
$T(n) = T(\sqrt{n}) + n$

Let $n = 2^m$

$T(2^m) = T(2^\frac{m}{2}) + 2^m$

Let $T(2^m) = S(m)$, then $T(2^\frac{m}{2}) = S(\frac{m}{2})$

Recurrence reduces to : $S(m) = S(\frac{m}{2}) + 2^m$

Now both back substitution and Master's Theorem can be applied.

$S(m) = O(2^m)$ ($m = log_2n)$

$\color{red}{T(n) =O(n)}$

Related questions

1 votes
1 votes
1 answer
2
Abhishek Malik asked Apr 6, 2018
330 views
$T(n)=T(\sqrt{n})+n$$T(2)=1$
2 votes
2 votes
2 answers
4