Consider the following recurrence relation:
$T(2) = 5$
$T(n) = 2T\left( {\left\lceil {{{2n} \over 3}} \right\rceil } \right) + T\left( {\left\lfloor {{n \over 3}} \right\rfloor } \right) + 3$
I got this recurrence relation by analysing the following algorithm:
I got $T(2) = 5$ as the base case because of 2 comparisons in the if statement plus 3 statements in swap() function.
The question requests to solve it using the characteristic equation. However, I don't know how to proceed with the constant $1$ at the end.
My attempt:
$a_n - a_{2n/3} - a_{n/3} = 3 \\ x^n - x^{2n/3} - x^{n/3} = 3 \\ x^{n/3}(x^3 - 2x^2 - 1) = 3$
Also, if I analysed incorrectly the algorithm, please tell me! All help is appreciated!
edit: I incorrectly deduced the recurrence equation. I didn't count the cost of first and second if statement.


Then you can solve your recurrence by putting $$ n = 3m + k = 3\left\lfloor {{n \over 3}} \right\rfloor + n\bmod 3 $$ and split the recurrence into a system three, one for each k.