The recurrence equation is below:
$$ {\rm T}\left(n\right) = 2\,{\rm T}\left(n \over 2\right) + 3\,{\rm T}\left(n \over 3\right) + n $$
- I've already tried to find a solution on the internet, but I was unsuccessful.
- My main question is if I should first solve $2\,{\rm T}\left(n/2\right)$ and then $3\,{\rm T}\left(n/3\right)\ ?$.
- Would I be able to use a Recursion Tree or Substitution Method to do it $?$.
The recurrence is $T(n)=2T(\frac n2)+3T(\frac n3)+n$. We have $T(\frac n2)=2T(\frac n4)+3T(\frac n6)+\frac n2$ and $T(\frac n3)=2T(\frac n6)+3T(\frac n9)+\frac n3$. Substituting these in the first equation we get $$T(n)=4T(\frac n4)+9T(\frac n9)+2\frac n2+3\frac n3+n=2T(\frac n2)+3T(\frac n3)+n$$ So the recurrence is solvable using the Master Theorem.