1

I made a recurrence tree and guessed that solution to $T(n)=2T(n-2)+n$ is $O(2^{n/2})$ and I am now trying to prove this through substitution. These are my steps so far, but I can't get it to pass for some reason:

\begin{align} T(n-2) &\leq c2^{(n-2)/2}\\ T(n) &= 2(c2^{(n-2)/2})+n\\ &\leq c2^{n/2} \quad (?) \end{align}

But as far as I see, it can never add up, because it will always be greater than the $+n$ term and times $2$. Any help will be much appreciated.

Yuval Filmus
  • 280,205
  • 27
  • 317
  • 514
manis
  • 121
  • 2

2 Answers2

1

The hints you've been given almost work. The important idea is that your guess, $T(n)≤c2^{n/2}$, while correct, doesn't behave nicely in your induction proof, as you noted. What's the problem? Clearly, it's that "$+n$" term in the recurrence, so let's try to make it work by choosing a better guess: $$ T(n)≤c2^{n/2}−kn \quad\text{for some suitable } k $$

With this guess, we'll have $$\begin{align} T(n)&=2T(n−2)+n\\ &\le 2(c2^{(n−2)/2}−k(n−2))+n\\ &=c2^{n/2}−2k(n−2)+n\\ &=c2^{n/2}−2kn+4k+n \end{align}$$ and if we can find a suitable $k$ to make this less than or equal to $c2^{n/2}−kn$ we'll be done. In other words, we need to find $k$ such that $$ −2kn+4k+n≤kn $$ It's not hard to see that this will happen if $$ k\ge\frac{n}{n−4} $$ and this will be satisfied when $k=5$ for any integer $n>4$. Now go back to the inductive proof and recast it for the guess $T(n)\le c2^{n/2}−5n$. You'll find that everything works nicely. Finally, observe that $c2^{n/2}−5n=O(2^{n/2})$ and you'll be done.

This is explained in a bit more detail in this answer to a similar question.

Rick Decker
  • 15,016
  • 5
  • 43
  • 54
0

Hint: Prove by induction that $$ T(n) = 2^{n/2} T(0) + 2^{n/2+2} - n - 4. $$ (See the calculation in my answer to your former question.) Alternatively, you can try proving by induction that $T(n) \leq c 2^{n/2} - n$, for an appropriate $c$. Let us know if that works.

More generally, what you call the substitution method is used to get a bound on some recurrence without solving the recurrence explicitly. If you already know the explicit solution, and the explicit solution yields itself to asymptotic analysis, then there is no reason to use the substitution method other than to get a possibly shorter proof, or one that is more easy to generalize.

I realize that there is one more reason, namely that the exercise requires you to use the substitution method, but in that case you can defeat this silly and narrow request by using the substituting method to find the exact asymptotics.

Yuval Filmus
  • 280,205
  • 27
  • 317
  • 514