I'm working on deriving this recurrence relation in the form $O(n^d)$ for some value of d:
$B(n) = 5\cdot B(\frac{n}{3}) + cn^2$
The initial condition is:
$B(1) = c$
I'm having trouble incorporating the n^2 into my derivation. This is what I have so far:
We set $n = 3^k$
$5^k(1 + \frac{5}{3} + (\frac{5}{3})^2 + ... + (\frac{5}{3})^k$
Which leads to $3^k\cdot (\frac{10}{3})^k$ -> $5^k = 5^{log_3n}$ -> $log_{3}n = k$
Not sure how to derive the final running time to be $O(n^d)$. Any help would be appreciated!
\begin{equation} \begin{split} B(n) &= 5B(\frac{n}{3}) + cn^2 \\ &= 5(5B(\frac{n}{3^2}) + c(\frac{n}{3})^2) + cn^2 \\ &= 5^2B(\frac{n}{3^2}) + c[5(\frac{n}{3})^2 + n^2] \\ &= 5^2(5B(\frac{n}{3^3}) + c(\frac{n}{3^2})^2) + c[5(\frac{n}{3})^2 + n^2] \\ &= 5^3B(\frac{n}{3^3}) + c[5^2(\frac{n}{3^2})^2 +5(\frac{n}{3})^2 + n^2] \\ &= \vdots \\ &= 5^kB(\frac{n}{3^k}) + c[5^{k-1}(\frac{n}{3^{k-1}})^2 + \ldots +5(\frac{n}{3})^2 + n^2]\\ &= 5^kB(\frac{n}{3^k}) + cn^2 \sum_{i=0}^{k-1} 5^i(\frac{1}{3^i})^2 \\ &= 5^kB(\frac{n}{3^k}) + cn^2 \sum_{i=0}^{k-1} (\frac{5}{3^2})^i \\ &= 5^kB(\frac{n}{3^k}) + cn^2 \frac{1-(\frac{5}{9})^k}{1- \frac{5}{9}} \end{split} \end{equation}
But $B(1) = c$ hence for $k=\log_3 n$ $$B(n) = 5^{\log_3 n}c + \frac{9}{4} cn^2 (1-(\frac{5}{9})^{\log_3 n})$$ It seems that the dominating term is $O(n^2)$.