T(n) = T(n/3) + 2T(2n/3) + n
First of all, we are able to guess that this is going to be something like n^c, since this is at least as much as R(n) = 2R(2n/3) + n. To analyze R(n), we see that: a = 2, b = 1.5, f(n) = n, which can be solved using MT, and gives a simple n^(log_1.5(2)), that is, n^(log 2/log 1.5), which is ~ n^1.71
Suppose T(n) <= k n^c
We want to choose any k, smallest c, such that following is true.
k n ^ c / 3^c + 2 k 2^c n^c / 3^c + n <= k n^c
As a sanity check, c >= 1. Based on previous analysis, we will see that c >= 1.71
- n <= n^c (k – k/3^c – 2 k 2^c / 3^c)
- 1 <= n ^ (c-1) k [1 – 1/3^c – 2 2^c / 3^c] // Our sanity check is reinforced here, c >= 1
Say c = 1, this becomes negative: 1 – 1/3 – 4/3 (Negative). So, this is not good. We want the term to be non-negative.
That is, we want that 1 - 1/3^c - 2 2^c /3^c >= 0
- 1/3^c + 2 2^c / 3^c <= 1
- 1 + 2 2^c <= 3^c
- 1 <= 3^c – 2 2^c
c >= 2