0

I am analyzing different ways to find the time complexities of algorithms, and am having a lot of difficulty trying to solve this specific recurrence relation by using a proof by induction.

My RR is: T(n) <= 2T(n/2) + √n

I am assuming you would assume n and prove n-1? Can someone help me out.

sve
  • 4,336
  • 1
  • 19
  • 30

2 Answers2

1

Let's assume T(0) = 0, T(1) = 1 (since you haven't given any trivial cases). Thus, we have: T(2) = 3.41, T(4) = 8.82, T(6) = 14.57, T(8) = 20.48, T(10) = 26.51. This seems like being a linear function.

So, we could assume T(n) <= C * n + o(n).

This can be proven by induction. Suppose T(k) <= C*(k) + o(k) = C*(k) + o(n). for each k<n.

We should prove T(n) <= C*n + o(n). Using the recurrence, T(n) <= 2*T(n/2) + sqrt(n) <= 2*(C*(n/2) + o(n)) + sqrt(n) = C*n + (2*o(n) + sqrt(n)) = C*n + o(n).

Thus, we have proven T(n) <= C*n + o(n), which guarantees that T(n) is at least O(n).

Also, it can be shown that the solution of T(x) = 2T(x/2) + sqrt(x), T(0)=0, T(1)=1 is T(x) = (2x-sqrt(2x))/(2-sqrt(2)).

h8red
  • 713
  • 4
  • 17
  • nice response, do you know a generic way of analytically solving the recurrence like T(x) = 2T(x/2) + sqrt(x)? – simon May 03 '16 at 23:19
  • @Vahan Simonyan These equations can be solved using [master theorem](https://en.wikipedia.org/wiki/Master_theorem). Even more complex recurrences may be solved by [Akra–Bazzi theorem](https://en.wikipedia.org/wiki/Akra%E2%80%93Bazzi_method). – h8red May 04 '16 at 21:26
  • As I understood Master theorem or Akra-Bazzi theorem answering to the question how T function behaves asymptotically. I am just want to know how you got that (2x-sqrt(2x))/(2-sqrt(2)) is the solution of T(x) = 2T(x/2) + sqrt(x), T(0)=0, T(1)=1 equation? Of course I can verify that by putting solution into equation, but is there some generic method for solving this kind of equations? Is it somehow related to differential equations? – simon May 04 '16 at 21:37
0

If using induction to prove, then assumption would be true for K and prove for 2*k or 2^k.

First, check for T(1):

T(1) <= 2T(1/2) + √n

(Assuming T(1/2) = 1) T(1) = 2 + √n <= O(√n log n)

Now, assuming it to be true for T(k).

=> T(k) <= O(√n log n) T(k) <= 2T(k/2) + √n <= c(√n log n)

Proving for, T(2k):

T(2k) <= 2T(2k/2) + √(2k)
=> T(2k) <= 2(c(√k log k) + √(2k)
=> T(2k) <= √2 * [2(c(k log k) + √(2k)] //(Inequality follows)
=> T(2k) <= [c'(2k log 2k)] => T(2k) <= O(√n log n)

Growth rates:

(c < log n < log2n < √n < n < n log nn < n log n < n(1.1) < n2 < n3 < n4 < 2n)

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Jahangir Ali
  • 55
  • 1
  • 14