2

In accord to Master Theorem this recurrece is θ(n^2), but if we solve this with tree recurrence the solution is θ(n^2*logn). Am I doing something wrong?

1 Answers1

2

If the recurrence relation is T(n) = 2T(n/2) + n^2, then you're in the third case of the master theorem, and the regularity condition applies, so T(n) = Theta(n^2). [c_crit is log_2(2) = 1, n^2 = Omega(n), 2(n/2)^2 = (n^2)/2 (so k<1, specifically k=1/2)]

If you expand out the recurrence relation by hand, then you get:

T(n) = n^2 + 2(n/2)^2 + 4(n/4)^2 + 8(n/8)^2 + ...
     = n^2 ( 1 + 1/2 + 1/4 + 1/8 + ...)
     <= 2n^2

So this method too gives you T(n) = Theta(n^2).

The method of inputting the recurrence relation into Wolfram Alpha and seeing what it says gives T(n) ~ 2n^2, so again Theta(n^2).

Paul Hankin
  • 54,811
  • 11
  • 92
  • 118
  • @AlfredoMungari if you found the answer helpful and it answered your question, you can consider upvoting the answer and accepting it. – Paul Hankin Feb 01 '21 at 15:31
  • How I can upvoting the answer and accepting it ? @PaulHankin –  Feb 01 '21 at 20:31
  • I think I can't upvote this answer because my reputation is less then 15 @PaulHankin –  Feb 01 '21 at 20:33