遞歸的解決類似積分,方法並不固定,也不一定能算出來,不過常用的方法有三種,能應付一般情況:
- substitution method(代換法):就是高中數學裏面的數學歸納法
- Recursion-tree(遞歸樹):就是把數學表達式都展開,但是用樹的形式表示
- Master Method(主方法):就是把最常見的遞歸表達形式總結爲定理:
比較f(n)和n^log(b^a)
- f(n)=Ο[n^log(b^(a-ε))],for some ε≧0,那麼T(n)=Θ(n^log(b^a))
- f(n)=Θ[n^log(b^a)*(lgn)^k],for some k≧0,那麼T(n)=Θ(n^log(b^a)*(lgn)^(k+1))
- f(n)=Ω[n^log(b^(a+ε)],for some ε≧0,那麼T(n)=Θ(f(n))