1

The required solution is given. I have to prove that its solution is $O(n\log n)$.

My idea is shown below:

I have to prove, $T(n) \le cn\log n$ for some constant $c$ $$\begin{align} T(n) &\le 2c\log(n/2) + n\\ &= 2c\log(n) - 2c\log(2) + n\\ &= 2c\log(n) - 2c + n\\ &= c\log(n) + ( c\log(n) - 2c + n )\\ &\le c\log(n) \end{align}$$ it will be true if $( c\log(n) - 2c + n ) \ge 0$.

Is my procedure is correct?

If no, can anyone tell me how I can solve this problem with appropriate value of $c$ and $n$?

If yes, then how I can find out appropriate value of c and n using this relation clog(n) - 2c + n ) >= 0.

Raphael
  • 72,336
  • 29
  • 179
  • 389
nahin100
  • 11
  • 1
  • In your proof you neglected to include the factor $n$. For instance, your first line should read $T(n)\le 2c(n/2)\log(n/2)+n$. With the appropriate fixes your proof will then work. – Rick Decker Jul 06 '15 at 23:47
  • 1
    In particular, look at the third answer to the question @D.W. suggested: "Guess and Prove". The technique suggested there won't always be so simple, but in your case it is. – Rick Decker Jul 07 '15 at 00:03

0 Answers0