Masters Theorem $T(n) = 2T(\frac{n}{4}) + (\log(n))^2$

algorithmscomputer sciencerecurrence-relations

I have a problem that I am trying to understand using the master theorem since it applys. The problem at hand is, $T(n) = 2T(\frac{n}{4}) + (\log(n))^2$. I am not sure I am correct in my final solution. The $\log(n)^2$ is what is causing me some doubt. I believe this recurrence relation satisfies case 1, see below. Any guidance or correction would be greatly appreciated! Here is my work:

  1. $T(n) = 2T(n/4) + (\log(n))^2$
  2. a = 2, b = 4, k = 0, p = 2
  3. following, $\log_b a$ or $\log_4 2 = .5$
  4. Since .5 > k = 0, we satisfy case 1
  5. Thus it is: $\Theta(n^{\log_4 2})$

Is this correct, and if not, where did I go wrong?

Best Answer

Step 4 could use some more work. Namely, you need to show that $(\log(n))^{2} \in O(n^{c})$ for some $c < 1/2$. This shouldn't be too hard. For example, take $c = 1/3$. We have that: \begin{align*} \lim_{n \to \infty} \frac{(\log(n))^{2}}{n^{1/3}} = 0. \end{align*}

I'll leave it to you to fill in the details for the limit computation.

So $(\log(n))^{2} \in O(n^{1/3})$ (actually, $(\log(n))^{2} \in o(n^{1/3}))$.

Your reasoning is otherwise fine.