当前位置: 代码迷 >> 综合 >> Recursion-tree Master Method
  详细解决方案

Recursion-tree Master Method

热度:40   发布时间:2024-02-09 10:44:36.0

递归表达式

T ( n ) = a T ( n / b ) + f ( n ) T(n) = aT(n/b) + f(n)

其中, a > = 1 , b > 1 a >= 1, b > 1 , f ( n ) f(n) 渐进趋正, 即由渐进分析可知, 存在某个 n 0 > 0 n_0 > 0 , 使得当 n > n 0 n > n_0 时, f ( n ) > 0 f(n)>0 .

比较 f ( n ) f(n) n log ? b a n^{\log_b{a}} 的大小, 可分为三种情况

case 1

f ( n ) = O ( n log ? b a ? ? ) f(n) = O(n^{\log_b{a}} - \epsilon) , for some ? > 0 \epsilon > 0

结论

T ( n ) = Θ ( n log ? b a ) T(n) = \Theta(n^{\log_b{a}}) .

case 2

f ( n ) = Θ ( n log ? b a ? lg ? k n ) f(n) = \Theta(n^{\log_b{a}} \cdot \lg^{k}n) , for some k > = 0 k >= 0

结论

T ( n ) = Θ ( n log ? b a ? lg ? k + 1 n ) T(n) = \Theta(n^{\log_b{a}} \cdot \lg^{k+1}n) .

case 3

f ( n ) = Ω ( n log ? b a + ? ) f(n) = \Omega(n^{\log_b{a}} + \epsilon) , for some ? > 0 \epsilon > 0 a n d and
             a f ( n / b ) < = ( 1 ? ? ) ? f ( n ) af(n/b) <= (1- \epsilon^{'} ) \cdot f(n) for some ? > 0 \epsilon^{'} > 0

结论

T ( n ) = Θ ( f ( n ) T(n) = \Theta(f(n) .

  相关解决方案