[Math] 2T(n/2) +n by induction

inductionrecursion

I try to proof by induction that:

$$ T(n)= 2 T(n/2)+n \quad n>2,\quad T(2)=2,\quad n = 2^{k}$$

is
$$ n*lg_2(n) $$

How can I do this?

Thanks

Steps that i went throw:

==Base Case==
$$T(2) = 2, \quad 2\cdot lg(2) = 2, \quad$$
My base case is verified

==Induction Step ==

Inductive hypothesis

$$ 2T((n+1)/2) +(n+1) = (n+1)\cdot lg_2(n+1)$$

I'm stuck here…

Best Answer

The reason you are confused is that (if I understand your problem correctly) $T(n)$ is defined only for $n = 2^k$, i.e. only when $n$ is a power of two.

Often when you do induction, you assume the statement is true for $n$, and then prove it is true for $n + 1$. But here, $T$ isn't even defined for $n + 1$ because it is only defined for powers of two. So you're going to have to be more clever.

You don't have to worry about $n + 1$ because it's not a power of two. What you do have to worry about is all the powers of two. So the way you would prove this by induction is, assuming it is true for $n$, prove it is true for the next power of two.

Letting $n = 2^k$, the next power of two is $2^{k+1}$. Therefore, you're going to want to assume that $$ T(n) = n \log_2 ( n ) \quad \textbf{for } \textbf{n = } \textbf{2}^\textbf{k} $$ and prove that $$ T(n) = n \log_2 (n) \quad \textbf{for } \textbf{n = } \textbf{2}^\textbf{k + 1}. $$