0

How to solve the recurrence equation $T(n)=2T(n/2) + n \lg n$

For ex: I implemented "Counting inversions" with a full mergesort instead of just using merge part, So the outer complexity will be $n \lg n$.

Also, What is the $O$(complexity) of above ?

Introduction to Algorithms, 3rd edition (p.95) has an example of how to solve the a similar recurrence $T(n)= 3T\left(\frac{n}{4}\right) + n \log(n)$ using master theorem by showing $f(n)$ is polynomially larger than $n^{\log_b a}$. But I am not sure about this one.

coder000001
  • 149
  • 2
  • No, It might be possible to solve using Master Theorem. – coder000001 Jun 04 '15 at 18:57
  • Yes, and this answer to the question I linked covers the Master Theorem, including your example, which is the case $a=b=2$, $k=1$. (I mean case 2 of the specific way that that answer phrases the theorem; other sources may present the cases in a different order and/or have different cases.) – David Richerby Jun 04 '15 at 19:01
  • I don't see k = 1 case, also can you check edited question. Can you edit your answer to include $T(n)=2T(n/2) + n \lg n$ in http://cs.stackexchange.com/a/2823/9550 – coder000001 Jun 04 '15 at 19:07
  • $T(n)=aT(n/b) + n^{\log_b a} \log^k n$ with $a=b=2$, $k=1$, gives exactly $T(n)=2T(n/2)+n\log n$. – David Richerby Jun 04 '15 at 19:14
  • Hence, as David said, in this case you'll have $T(n)=\Theta(n\lg^2n)$. – Rick Decker Jun 05 '15 at 01:34

0 Answers0