Inductive Proof Algorithm

70 Views Asked by At

so I'm working on an algorithms assignment and am having a tough time understanding what to do:

The equation is: $$T(n) = 2T(n/4) + n = \Theta(n) = O(n)$$

Right now I have gotten this far: $$T(1) = 1$$ This is because T(1) is constant time Base Case = 4 so you have $$2T(4/4) + 4$$

My guess is that $$T(n) \leq c*nlogn$$

So my hypothesis is that $$T(n) \leq c*nlogn$$ $\forall n=4,...,k$

This is where I'm stuck. Trying to figure out the inductive step of the solution. I have it looking like $$T(k+1) = 2T((k+1)/4) + (k+1)$$

Am I on the right track? Any help would be greatly appreciated. I'm sorry if this isn't formatted correctly, I'm learning $\LaTeX$ and did what I could.

2

There are 2 best solutions below

0
On

The recursion we are trying to solve is

$$T(n) = 2T\left(\frac{n}{4}\right)+n$$

This follows the typical form of the Master Theorem, where

$$T(n) = aT\left(\frac{n}{b}\right)+f(n)$$

and we can calculate the solution immediately as

$$T(n)=\Theta(f(n))=\Theta(n)$$

Suppose we do not have access to the Master Theorem, and we want to prove this inductively. While the inductive hypothesis $T(n) \le cn\log{n}$ is true, since we already know the solution, we can obtain a tighter bound.

Let the inductive hypothesis be $$T(n) \le cn$$ for all $n \in \mathbb{N}$ and sufficiently large $c$, which is a free constant we can identify later.

The base case is clear, since by assumption $T(1)$ is a constant.

By strong induction, let us assume the claim is true for all integers less than $n$. In particular, it is true for $n/4$. Hence

$$ \begin{align} T(n) &= 2T(n/4) + n\\ & \le 2c\frac{n}{4} + n && \text{by hypothesis}\\ & = n(\frac{c}{2}+1)\\ & \le cn && \text{for } c\ge2 \end{align} $$

which completes the proof.

0
On

Since the number $4$ is important in $T(n) = 2T(n/4) + n$, let $n = 4^m$. This becomes $T(4^m) =2T(4^{m-1})+4^m $.

Now, let $s(m) =T(4^m) $. That becomes $s(m) =2s(m-1)+4^m $. Dividing by $2^m$, this becomes $\frac{s(m)}{2^m} =\frac{s(m-1)}{2^{m-1}}+2^m $. Letting $r(m) = \frac{s(m)}{2^m}$, we get $r(m) =r(m-1)+2^m $ or $r(m)-r(m-1)=2^m $.

Summing from $m=1$ to $M$, $r(M)-r(0) =2^{M+1}-2 $.

Unwinding, since $r(0) = s(0) =T(1) =1 $ and $r(M) =2^{M+1}-1 $, $s(m) =2^mr(m) =2^m(2^{m+1}-1) =2 4^m-2^m $ so $T(4^m) =2\ 4^m-2^m $ which shows that $T(n) =\Theta(n) $, at least for powers of $4$.