T(n) = 2T(n/2) + 5n^2
T(1) = 7
T(n/2) = 2T(n/2) + 5(n/2)^2
Eventually I can write this out in general form:
T(n) = 2^k * T(n/2^k) + 5(n/2^(k-1))^2 * (2^(k-1) + ... 2^0)
I'm struggling with understanding how I would write out the second part as a summation
Because of the (n/2^(k-1))^2 I would expect for the resulting summation to look something like
$\sum_{i=0}^k \frac{1}{2^i}^2$
(The exponent is for the entire fraction, the denominator should be $(2^i)^2$, and the upper bound should be k-1
However the correct answer is simply $1/2i$
I can use a summation identity to eventually solve the question, I'm having trouble correctly writing out what the general form summation would look like.
As an aside, when can I use the master theory to solve these types of questions? Thank you!
T(n) = aT(n/b) + cn^k
Your summation is incorrect. If you draw this as a recursion tree, you will notice that there are $\lg n$ steps before you reach $T(1)$. Also, observe that there is a $2$ multiplied with $T\left(\dfrac n2\right)$ which means you have to multiply it with the entire expression for $T\left(\dfrac n2\right)$.
$$ \begin{align} T(n) &= 2T\left(\frac n2\right) + 5n^2 \\ &= 2\left(2T\left(\frac n4\right) + 5\left(\frac n2\right)^2\right) + 5n^2 = 4T\left(\frac n4\right) + 5\left(\frac{n^2}2\right) + 5n^2 \\ &= 4\left(2T\left(\frac n8\right) + 5\left(\frac n4\right)^2\right) + 5\left(\frac{n^2}2\right) + 5n^2 = 8T\left(\frac n8\right) + 5\left(\frac{n^2}4\right) + 5\left(\frac{n^2}2\right) + 5n^2 \\ &\qquad\qquad\vdots \\ &= nT(1) + 5\left(\frac{n^2}{2^{\lg (n - 1)}}\right) + 5\left(\frac{n^2}{2^{\lg(n - 2)}}\right)+\cdots + 5\left(\frac{n^2}4\right) + 5\left(\frac{n^2}2\right) + 5n^2 \\ &= 7n + 5{\color{red}{\sum_{i = 0}^{\lg (n) - 1}\frac{n^2}{2^i}}} = 7n + 5\cdot 2n(n - 1) = 10n^2 - 3n = \Theta\left(n^2\right) \end{align} $$