Recursive Closed Forms



Recursion Tree





Recursion Tree and Examples



Tree Properties



Recursion Tree for $T(n) = aT(\frac{n}{b}) + f(n)$

$T(n)=$\begin{cases} d & \text{if }n=1\\ a\times T(n/b)+f(n) & \text{otherwise} \end{cases}, where $n$ is a power of $b$.





$t(k)=$\begin{cases} d & \text{if }k=0\\ a\times t(k-1)+f(b^{k}) & \text{otherwise} \end{cases}
---> So, in general
$t(k)=a^{k}\times t(0)+\sum_{i=0}^{k-1}a^{i}f(b^{k-i})=a^{k}\times d+\sum_{i=0}^{k-1}a^{i}f(b^{k-i})$
$T(n)=d\times a^{\text{log}_{b}n}+\sum_{i=0}^{\text{log}_{b}n-1}a^{i}f(\frac{n}{b^{i}})$



An Application of the Formula

---> Consider the following recurrence, defined for $n$ which is a power of 4 (for the time of some algorithm.)
$T(n)=\begin{cases} 3 & \text{if }n=1\\ 2T(n/4)+4n+1 & \text{otherwise} \end{cases}$
---> This recurrence equation is equivalent to
$t(k)=\begin{cases} 3 & \text{if }k=0\\ 2\times t(k-1)+4\times4^{k}+1 & \text{otherwise} \end{cases}$
---> Using the formula that we derived above, we could obtain \begin{array}{ccc} T(n) & = & 3\times2^{\text{log}_{4}n}+\sum_{i=0}^{\text{log}_{4}n-1}2^{i}\times\left[4\times\frac{n}{4^{i}}+1\right]\\ & = & 3\times n^{\frac{1}{2}}+4n\times\sum_{i=0}^{\text{log}_{4}n-1}\frac{1}{2^{i}}+\sum_{i=0}^{\text{log}_{4}n-1}2^{i}\\ & = & 3\times n^{\frac{1}{2}}+4n\times\frac{1-\left(\frac{1}{2}\right)^{\text{log}_{4}n}}{1-\frac{1}{2}}+\frac{1-2^{\text{log}_{4}n}}{1-2}\\ & = & 3\times n^{\frac{1}{2}}+8n\times(1-\frac{1}{n^{\frac{1}{2}}})+n^{\frac{1}{2}}-1\\ & = & 8n-4n^{\frac{1}{2}}-1 \end{array}

Evaluating the Complexity of the Sum of the Tree Levels