0

I need to prove that $T(n) = 4T(n/2) + n^2lgn = \mathcal{O}(n^2lg^2n)$ by using the substitution method. Unfortunately, I'm not able to identify the error in my train of thought.

For the problem at hand, I want to prove that $T(n) = \mathcal{O}(n^2lg^2n)$, equivalently that there exists a $n_0$ and $c > 0$ such that for every $n \geq n_0$ it holds that $T(n) \leq cn^2lg^2n$. So it follows that: \begin{align} T(n) &= 4T(n/2) + n^2lgn \\ &\leq 4c\left(\frac{n}{2}\right)^2lg^2\left( \frac{n}{2} \right) + n^2lgn \\ &= cn^2lg^2n - cn^2 + n^2lgn \\ &\leq cn^2lg^2n \end{align}

The last inequation holds when $$ - cn^2 + n^2lgn \leq 0 $$ or, equivalently $$ c \geq lgn $$

which cannot be true since $\lim_{n \rightarrow \infty} lgn = \infty$.

I would be very thankful to anyone who can point to where my error comes from, or at least point me in the right direction.

Thank you in advance! :)

1 Answers1

1

You made a mistake in algebra.

Assuming $lg\ 2 = 1$,

\begin{align} T(n) &= 4T(n/2) + n^2lgn \\ &\leq 4c\left(\frac{n}{2}\right)^2lg^2\left( \frac{n}{2} \right) + n^2lgn \\ &= cn^2(lg\ n-lg\ 2)^2 + n^2lgn \\ &= cn^2(lg\ n-1)^2 + n^2lgn \\ &= cn^2(lg^2\ n-2lg\ n+1) + n^2lgn \\ &= cn^2lg^2n-2cn^2lg\ n+cn^2 + n^2lgn \\ &= cn^2lg^2n-n^2lg\ n(2c-1)+cn^2 \\ \end{align}

To make this less than $ cn^2lg^2n$, we must have $2c-1 < 0 $ or $c < \frac12$ (assuming I did not make my own mistake).

marty cohen
  • 107,799