[Math] Master theorem $T(n)=2T(n/4)+ \sqrt{n}+\log^2(n)$

algorithms

How to know if master theorem applies here: $T(n)=2T(n/4)+ \sqrt{n}+\log^2(n)$.

I don't know how to take $f(n) = \sqrt{n} + \log^2(n)$ because it seems that is not included in none of the three cases.

Can someone please explain me the logic of this exercise?

Best Answer

The point of this recurrence is finding a $n^k$ upper bound of $f(n)$.

In this case, you can apply

Let $a, b, c \in \mathbb R$ such that $a >0$, $b > 1$, $c > 0$. Then, $$(\log_b n)^a \subset \mathcal O(n^c)$$

so $$f(n) = \sqrt{n} + \log^2(n) \subset \mathcal O(\sqrt{n}) = \mathcal O(n^{0.5})$$

You can also prove that $\log^2 (n) \subset \mathcal O(\sqrt{n})$ by taking limits and using L'Hôpital's Rule.

Finally, as long as $$T(n) = 2\;T(n/4) + \mathcal O(n^{0.5})$$ you're ready to apply Master theorem.