I understand that the Master Theorem and recursion tree can be used for "divide-and-conquer" recurrence relations (ie T(n)=T(n/2)+1 ).
However, how would I apply those concepts to T(n)=T(n-1)+logn?
To my understanding, you cannot apply the two concepts to (n-1) decrements. But the assignment and professor are requiring T(n)=T(n-1)+logn to be solved using recursion trees and master theorem.
Furthermore, is there any reason that the following is not the recursive expansion for the above function?
T(n)=T(n-3)+log(n-2)+log(n-1)+log(n)
According to my professor, it should not be log(n-2) and log(n-1) but rather
T(n)=T(n-3)+logn+logn+logn
which makes absolutely no sense to me.
The following is a subtractive version of the master theorem:
If T(n) = aT(nc) + g(n) where c>=1 and g(n)=Theta(n^k) for k>=0, then
It does not include the particular case you ask, but states a general result on decrements.
Two things,
The recursive definition states that you must replace n
with n-1
when calling T(n)
again, so your logic is sound for T(n)=T(n-3)+log(n-2)+log(n-1)+log(n)
.
Your can easily make the argument that log(1) + log(2) + log(3) + ... log(n) = log(n!) = Theta(nlogn)
, and log(n) + log(n) + log(n) ... + log(n) = nlog(n) = Theta(nlog(n))
http://en.wikipedia.org/wiki/Factorial#Rate_of_growth_and_approximations_for_large_n
http://en.wikipedia.org/wiki/Stirling%27s_approximation
To look at it as a tree, it's actually just a tree with worst case height, ie
This is because at each call, There is only one subproblem to solve.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.