Solution of recurrence

54 Views Asked by At

I need some explanations at the proof of the following theorem.

Theorem:

Let $a$, $b$ and $c$ be nonnegative constants.

The solution to the recurrence $$T(n)=\left\{\begin{matrix} b & ,\text{ for } n=1\\ aT(n/c)+bn & ,\text{ for } n>1 \end{matrix}\right.$$ for $n$ a power of $c$ is $$T(n)=\left\{\begin{matrix} O(n) & ,\text{ if } a<c\\ O(n \log n) & ,\text{ if } a=c\\ O(n^{\log_c a}) & ,\text{ if } a>c \end{matrix}\right.$$

Proof:

If $n$ is a power of $c$, then $$T(n)=bn \sum_{i=0}^{\log_c n} r^i, \text{ where } r=a/c$$

If $a<c$, then $\displaystyle{\sum_{i=0}^{\infty}r^i}$ converges, so $T(n)$ is $O(n)$.

If $a=c$, then each term in the sum is unity, and there are $O(\log n)$ terms. Thus $T(n)$ is $O(n \log n)$.

Finally, if $a>c$ then $\displaystyle{bn\sum_{i=0}^{\log_c n} r^i=bn\frac{r^{1+\log_c n}-1}{r-1}}$, which is $O(a^{\log_c n})$ or equivalently $O(n^{\log_c a})$.

$$$$

My questions are the following:

  1. Why is $T(n)$ equal to $bn \sum_{i=0}^{\log_c n} r^i$, where $r=a/c$ if $n$ is a power of $c$ ??

  2. If $a<c$: why does $\displaystyle{\sum_{i=0}^{\infty}r^i}$ converge??

  3. If $a=c$: why is each term of the sum unity??

  4. If $a>c$: why does $\displaystyle{bn\sum_{i=0}^{\log_c n} r^i=bn\frac{r^{1+\log_c n}-1}{r-1}}$ only in this case??

1

There are 1 best solutions below

6
On

Suppose that $n=c^k$. In this case $k=\log_cn$. \begin{align} T(1) &= 1\\ T(c) &= aT(1)+bc=ab+bc=bc\big(\frac{a}{c}+1\big)=bc(1+r)\\ T(c^2)&= aT(c)+bc^2=aT(c)+bc^2=bc^2(1+r+r^2)\\ \cdots\\ T(c^k)&=aT(c^{k-1})+bc^k=bc^k\sum_{j=0}^{\log_cn} r^j. \end{align} Remember $r=\frac{a}{c}$ and geometric seri $\sum_{j=0}^{\infty}r^j$ converges iff $|r|<1$ and in this case the partial sum of the series is $\frac{1-r^n}{1-r}$ and the geometric series diverges iff $|r|>1$. The answer for the questions 2-4.