I have been trying to solve the following recurrence relation
$$T(n)=2T(\frac{n}{2}) + nlgn$$ by using substitution method.
I started to compute $T(1)$ ,$T(4)$,$T(8)$,$T(16)$ to guess a solution as below:
$$T(1)=1$$ $$T(2)=2+2lg2=4$$ $$T(4)=8+8lg2=16$$ $$T(8)=32+24lg2=56$$ $$T(16)=112+64lg2=176$$
My guess is that $T(n)$ should be something like $nlg^2n$ but I couldn't get a correct term.
Can anyone improve my guess?
At each step, we replace $n$ with $n/2$ and multiply the equation by $2$: \begin{align*} T(n) - 2T(\tfrac{n}{2}) &= n\lg n \\ 2T(\tfrac{n}{2}) - 2^2T(\tfrac{n}{2^2}) &= n\lg \tfrac{n}{2} \\ 2^2T(\tfrac{n}{2^2}) - 2^3T(\tfrac{n}{2^3}) &= n\lg \tfrac{n}{2^2} \\ 2^3T(\tfrac{n}{2^3}) - 2^4T(\tfrac{n}{2^4}) &= n\lg \tfrac{n}{2^3} \\ &~~\vdots \\ 2^{\lg n - 1}T(2) - 2^{\lg n}T(1) &= n\lg2 \\ \end{align*} Summing the $\lg n$ equations together, we note that the LHS telescopes, yielding: \begin{align*} T(n) - 2^{\lg n}T(1) &= n\sum_{k=0}^{\lg n - 1} \lg \tfrac{n}{2^k} \\ T(n) - n \cdot 1 &= n\sum_{k=0}^{\lg n - 1} (\lg n - k) \\ T(n) - n &= n\sum_{k=0}^{\lg n - 1}\lg n - n\sum_{k=0}^{\lg n - 1} k \\ T(n) - n &= n(\lg n)(\lg n) - n\frac{(\lg n)(\lg n - 1)}{2} \\ T(n) &= \frac{1}{2}n\lg^2 n + \frac{1}{2}n \lg n + n \end{align*} Thus, we conclude that $T(n) = \Theta(n \lg^2 n)$, which you suspected.