虚拟机――WMware
2015-11-12 17:33
423 查看
1. Assumption:
a) Base Case : T(n) <= a constant for all sufficiently small n
b) For all sufficiently large n : T(n) <= a T(n/b) + O(n^d) , where:
i) a = number of recursive calls on subproblems ( >= 1)
ii) b = input size shrinkage factor ( > 1)
iii) d = exponent in running time of "combine step" (>= 0)
iv) a, b, d are independent of n
2. Master Method :
if T(n) <= aT(n/b) + O(n^d)
O (n^d log n ) , a = b^d
T(n) = O (n^d) , a < b^d
O (n^ (logb a) ) , a > b^d
3. For recursion tree, at each level j=0, 1, 2, ..., logb n , there are a^j subproblems each of size n/b^j.
Total work at level j ( ignore work in recursive call ) <= a^j X c (n/b^j)^d = cn^d X (a/b^d)^j
a = rate of subproblem proliferation ( RSP)
b = rate of work shrinkage (RWS )
i) If RSP < RWS, then the amount of work is decreasing with the recursion level j.
==> most work at root
ii) If RSP > RWS, then the amount of work is increasing with the recursion level j.
==> most work at leaves
iii) If RSP and RWS are equal, then the amount of work is the same at every recursion level j.
==> same amount of work each level
Total work <= cn^d X sum ( (a/b^d)^j ) (j=1~logb n)
4. If a = b^d , then (a/b^d) ^j =1 , so the total work <= cn^d X (logb n +1 ) = O(n^d log n )
( logb n = logk n / logk b = 1/logk b X logk n , so b is not important for logb n , it can be any value , only a constant factor difference)
let r = a/b^d , 1 + r + r^2 + r^3 + ... + r^k = r^(k+1) -1 / r - 1
if r < 1 is constant , 1 + r + r^2 + ... + r^k <= 1/ (1-r) = a constant (1st item of sum dominates)
(i.e. 1/2 + 1/4 + 1/8 + ... <= 1/2 * 2 )
so the total work <= cn^d X 1/(1-r) = O (n^d)
if r > 1 is constant , 1 + r + r^2 + ... + r^k <= r^k ( 1+ 1/r-1) ( last item of sum dominates)
so the total work <= cn^d X logb n X r^logb n = O ( a ^ logb n ) ( note : (1/b^d) ^logb n = 1/n^d) = O(n^logb a)
actually a^logb n is the number of leaves of the recursion tree.
a) Base Case : T(n) <= a constant for all sufficiently small n
b) For all sufficiently large n : T(n) <= a T(n/b) + O(n^d) , where:
i) a = number of recursive calls on subproblems ( >= 1)
ii) b = input size shrinkage factor ( > 1)
iii) d = exponent in running time of "combine step" (>= 0)
iv) a, b, d are independent of n
2. Master Method :
if T(n) <= aT(n/b) + O(n^d)
O (n^d log n ) , a = b^d
T(n) = O (n^d) , a < b^d
O (n^ (logb a) ) , a > b^d
3. For recursion tree, at each level j=0, 1, 2, ..., logb n , there are a^j subproblems each of size n/b^j.
Total work at level j ( ignore work in recursive call ) <= a^j X c (n/b^j)^d = cn^d X (a/b^d)^j
a = rate of subproblem proliferation ( RSP)
b = rate of work shrinkage (RWS )
i) If RSP < RWS, then the amount of work is decreasing with the recursion level j.
==> most work at root
ii) If RSP > RWS, then the amount of work is increasing with the recursion level j.
==> most work at leaves
iii) If RSP and RWS are equal, then the amount of work is the same at every recursion level j.
==> same amount of work each level
Total work <= cn^d X sum ( (a/b^d)^j ) (j=1~logb n)
4. If a = b^d , then (a/b^d) ^j =1 , so the total work <= cn^d X (logb n +1 ) = O(n^d log n )
( logb n = logk n / logk b = 1/logk b X logk n , so b is not important for logb n , it can be any value , only a constant factor difference)
let r = a/b^d , 1 + r + r^2 + r^3 + ... + r^k = r^(k+1) -1 / r - 1
if r < 1 is constant , 1 + r + r^2 + ... + r^k <= 1/ (1-r) = a constant (1st item of sum dominates)
(i.e. 1/2 + 1/4 + 1/8 + ... <= 1/2 * 2 )
so the total work <= cn^d X 1/(1-r) = O (n^d)
if r > 1 is constant , 1 + r + r^2 + ... + r^k <= r^k ( 1+ 1/r-1) ( last item of sum dominates)
so the total work <= cn^d X logb n X r^logb n = O ( a ^ logb n ) ( note : (1/b^d) ^logb n = 1/n^d) = O(n^logb a)
actually a^logb n is the number of leaves of the recursion tree.
相关文章推荐
- IOS 解析XML文档 使用TBXML
- Java裁剪压缩PNG图片,透明背景色变黑问题解决
- 使用SpringAOP 处理异常
- SOJ 3531_Number Pyramids
- android任务和返回栈完全解析
- apache相关软件下载
- 用servelet滑动选择框实现数字运算
- (PHP)用cURL登录慕课网并下载个人空间页面
- htmlcleaner+xpath爬取
- css圆角 四边投影
- Surface Shader Examples 详解
- java获取当前路径的几种方法
- 插件--滚动插件slimScroll
- Java控制台命令
- Python正则表达式如何进行字符串替换
- golang不定参数
- 范冰冰索赔千万 细数那些经常“被代言”的明星
- UITextView添加planceholder
- android 关于Toast重复显示解决方法
- RCP 运行application,product时无法执行 Incompatible JVM提示 解决方法