I know what the O(lg n) and the T(n) mean, and in algorithm analysis I don’t know how to calculate the T(n) = 3T(n/3) + O(lg n). Should I expand it?
Just like:
T(n) = 3^2 *T(n/3^2) + O(lg n/3) + O(lg n) and so on...
then I get
T(n) = 3^(log b^n) * T(1)+ 3^[log b ^ (n-1)]* lg (n/(3^[log b ^(n-1)])) ...+ O(lg n/3) +O(lg n)
But how can I get the right answer, and can I get an easy way to find it out?
I think you can use Masters Theorem.
which implies the answer as
BigTheta(n)For Masters theorem formula plz see Wikipedia. There are three rules and are quite simple