If we assume T(n) is constant for small n, how can we find the solution of this function?
T(n) = T(n−2) + 2logn
So far, I am unable to find a way to represent the whole function. Can you please help me? I really want to understand.
Assuming n is even, and that T(1) = T(0) = 0
.
T(n)/2 = log(n) + log(n-2) + ... + log(2)
= log((n/2)! * 2^n)
= n log(2) + log((n/2)!)
= n log(2) + n log(n) - n + O(log(n)) (Stirling's approximation)
So for n
even, T(n) = Theta(n log(n))
.
For n
odd, you can note that T(n-1) < T(n) < T(n+1)
, and get the same asymptotic bound.