if assume that T(n) = 2T(3n/10) + T(4n/10) + n <= cnlogn

T(n) <= 6cn/10 * log(3n/10) + 4cn/10 * log(4n/10) + n
= cn/10 * (6(log3 + logn - log10) + 4(log4 + logn - log10)) + n
= cn/10 * (10logn - 10log10 + 6log3 + 4log4) + n
= cnlogn - cn/10 * (10log10 - 6log3 - 4log4) + n <= cnlogn

because (10log10 - 6log3 - 4log4) > 0, there exists c that satisfy the equation.

I think it is the tight upperbound because I failed when I assumed the T(n)<=cn so I think that upper bound of T(n) = O(nlogn)

am I doing right?

  • 1
    $\begingroup$ What are you trying to do? I find your post mostly incomprehensible. a) You don't state your goal. b) That calculation is given without any logical context (what we'd call a proof). c) You failing to prove something is no proof of the opposite. $\endgroup$ – Raphael Apr 4 '16 at 7:53
  • $\begingroup$ Our reference question may help. $\endgroup$ – Raphael Apr 4 '16 at 8:00
  • $\begingroup$ Note that you can use LaTeX here to typeset mathematics in a more readable way. See here for a short introduction. $\endgroup$ – Raphael Apr 10 '16 at 12:33

You can prove this using induction, but it will be messy. I'll show you a better approach below (unless you explicitly want to solve it using induction).

Yes, the answer is $O(n \log n)$, which follows most easily using the Akra-Bazzi method. (This is a generalization of the better-known Master theorem, and is extremely useful for solving these types of recurrences.)

Clearly, the recursion satisfies the form from the statement of the Akra-Bazzi theorem: $g(x)=x$, and the constants $a_i$ and $b_i$ obviously satisfy the requirements.

In your case, $b_1=3/10$ and $a_1=2$; and $b_2=4/10$ and $a_2=1$. Thus $a_1\cdot b_1 + a_2\cdot b_2=1$, thus we take $p=1$. By the Akra-Bazzi theorem, the solution is $T(x) = O(x \cdot (1 + \int_1^x \frac{g(u)}{u^{p+1}} du))$. Because $p=1$ we are integrating the function $x/x^2=1/x$.

Since $\int_1^x \frac{1}{u} du = \log x$, we have that $T(x) = O(x (1 + \log x))$ which is $O(x \log x)$.

Using variable $n$ instead of $x$, we state this in more familiar notation: $T(n) = O(n \log n)$.

In fact, Akra-Bazzi gives us a stronger result that $T(n) = \Theta(n \log n)$, from which it immediately follows that $T(n) = O(n \log n)$. This is because $f(n) = \Theta(g(n))$ if and only if $f(n) = O(g(n))$ AND $f(n) = \Omega(g(n))$.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy