$T(1) = 1 , T(n) = 2T(n/2) + n^3$? Divide and conquer, need help, I dont know how to solve it?
|
|
The homogeneous part of the equation $T(n) =2 T(n/2)$ has the general solution $$T_0(n) = C n.$$ So all what we have to do is find a particular solution of the inhomogeneous equation $$T(n) = 2 T(n/2) + n^{3} .$$ Quite often it is good to try an ansatz which has the same form as the inhomogeneous term. Therefore, we try $T_p(n) = c n^3$ which yields $$c n^3 = \frac{c}{4} n^3 + n^3.$$ Solving for $c$, we get the particular solution $T_p(n)= \frac{4}{3} n^3$. The general solution therefore has the form $T(n) =T_0(n) + T_p(n)$. With the initial condition $T(1)=1$, we obtain $C= - \frac{1}{3}$. So the solution is given by $$ T(n) = \frac{n}{3} (4 n^2 -1). $$ |
|||||||||||||||||
|
|
Use Akra-Bazzi which is more useful than the Master Theorem. Using Akra-Bazzi, I believe you get $$T(x) = \theta(x^3)$$ You can also use the Case 3 of Master theorem in the wiki link above. (Note: That also gives $\theta(x^3)$.) |
|||||||||||
|
|
Hmm, possibly another way of heuristics is instructive. $$\begin{array} & & a(2^k) &= & 2^k*\frac{4^{k+1}-1}{4-1} \\\ & &= & 2^k*\frac{4*(2^{k})^2-1}{3} \\\ \text{assuming }& k&=& \frac{\log(n)}{\log(2)} \\\ & a(n) &=& n*\frac{4*n^2-1}{3} \\\ & &=& n^3 + \frac{(n-1)n(n+1)}{3!} \\\ & &=& n^3 + 2*\binom{n+1}{3} \\\ \end{array} $$ where the expression in the fourth line is the same as Fabian's result. |
||||
|
|