master theorem
Posted Wujunde
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了master theorem相关的知识,希望对你有一定的参考价值。
The master theorem concerns recurrence relations of the form:
- {\displaystyle T(n)=a\;T\!\left({\frac {n}{b}}\right)+f(n)} where {\displaystyle a\in \mathbb {N} {\mbox{, }}1<b\in \mathbb {R} }
In the application to the analysis of a recursive algorithm, the constants and function take on the following significance:
- n is the size of the problem.
- a is the number of subproblems in the recursion.
- n/b is the size of each subproblem. (Here it is assumed that all subproblems are essentially the same size.)
- f (n) is the cost of the work done outside the recursive calls, which includes the cost of dividing the problem and the cost of merging the solutions to the subproblems.
It is possible to determine an asymptotic tight bound in these three cases:
Case 1
Generic form
where (using big O notation)
then:
Example
As one can see from the formula above:
- , so
- , where {\displaystyle c=2}
Next, we see if we satisfy the case 1 condition:
- .
It follows from the first case of the master theorem that
(indeed, the exact solution of the recurrence relation is , assuming).
Case 2
Generic form
If it is true, for some constant k ≥ 0, that:
- where
then:
Example
As we can see in the formula above the variables get the following values:
- where {\displaystyle c=1,k=0}
Next, we see if we satisfy the case 2 condition:
- , and therefore, {\displaystyle c=\log _{b}a}
So it follows from the second case of the master theorem:
Thus the given recurrence relation T(n) was in Θ(n log n).
(This result is confirmed by the exact solution of the recurrence relation, which is, assuming .)
Case 3
Generic form
If it is true that:
- where {\displaystyle c>\log _{b}a}
and if it is also true that:
- for some constant {\displaystyle k<1} and sufficiently large (often called the regularity condition)
then:
Example
As we can see in the formula above the variables get the following values:
- , where {\displaystyle c=2}
Next, we see if we satisfy the case 3 condition:
- , and therefore, yes, {\displaystyle c>\log _{b}a}
The regularity condition also holds:
- , choosing
So it follows from the third case of the master theorem:
Thus the given recurrence relation T(n) was in Θ(n2), that complies with the f (n) of the original formula.
(This result is confirmed by the exact solution of the recurrence relation, which is , assuming .)
from wikipedia
---------------------------------------------------------------------------------------------------------------------------------------------
it means lim(n->Infinity)(f(n)/n^(b lg a)) should 1. ->Infinity && f(n)/n^(b lg a) 2. (f(n)/n^(b lg a)< n^x for x>0.
if 1 but not 2 can‘t use the method. as f(n)/n^(b lg a) = n*lgn/n = lgn.
以上是关于master theorem的主要内容,如果未能解决你的问题,请参考以下文章
K8S——单master节点和基于单master节点的双master节点二进制部署(本机实验,防止卡顿,所以多master就不做3台了)
master 分支和 'origin/master' 已经发散了,如何' undiverge' 分支'?