有這樣一個遞歸的式子:T(n)=4T(2n)+n Two step:guess,assume and verify
guess: T(n)=O(n3)
assume and verify: replace of T(n) and T(n/2) with O(n3) and verify whether the equation is satisfied
接下來會使用其它的假設來尋找更加接近的結果
遞歸樹
recursive tree 是最簡單和直接的方法
有這樣一個遞歸的式子:T(n)=T(n/4)+T(n/2)+n2
next I will use left represent left child of the root and right…
the root is n2 the left is T(n/4) , the right is T(n/2)
then we will replace the leaf T(n/4) with T(n/16)+T(n/8)+n/42 and the same as &T(T/2)&
Finally we will get a recursive tree like this:
我們可以由級數的公式求出最終的結果
主方法
主方法有很多的限制,首先它是針對形如這樣的式子的解法T(n)=aT(n/b)+f(n) and f(n)>0whenn>n0
有如下的情況:
case1:
for f(n)=O(nlogba−ε)forsomek>=0 T(n)=Θ(nlogba)
case2: f(n)=Θ(nlogba(log2n)k)forsomek>=0 T(n)=Θ(nlogba(log2n)k+1)
case3: f(n)=Ω(nlogba−ε)forsomek>=0 and af(n/b)<(1−ε)f(n) T(n)=Θ(f(n))
一些應用會在下一節給出