Master theorem and Akra-Bazzi theorem

1. Master theorem

 

The main theorem is an important conclusion in algorithm analysis. It is mainly used to solve the asymptotic complexity of recursive algorithms designed based on the divide and conquer idea. This conclusion was originally made in 1980 by three computer scientists, Jon Bentley, Dorothea Haken, and James B. Saxe. Among them, Jon Bentley is the author of the best-selling book "Programming Pearls" in the computer field. He also proposed the use of KD-Tree. Data structure for multidimensional data management. The classic textbook "Introduction to Algorithms" named the conclusion as the main theorem and made it famous.

 

First look at the simplified version of the main theorem:

Consider T(n)=aT(n/b)+\Theta(n^d)the recursive form,

  • If a>b^d, then T(n)=\Theta(n^{\log_ba});
  • If a=b^d, then T(n)=\Theta(n^d\log n);
  • If a<b^d, then T(n)=\Theta(n^d).

Note that in this simplified version, the part on the right side of the addition must be polynomial.

How to apply the main theorem? Let's look at a few sample questions.

Example 1:T(n)=T(2n/3)+1

Apply the above formula, where a=1, b=3/2, and d=0, ie a=b^d. Therefore, available T(n)=\Theta(\log n).

 

The real version of the main theorem is given below:

Consider T(n)=aT(n/b)+f(n)the recursive form,

  • If it exists \epsilon>0, so f(n)=O(n^{\log_b a -\epsilon}), then T(n)=\Theta(n^{\log_ba});
  • If f(n)=\Theta(n^{\log_b a}), then T(n)=\Theta(n^{\log_ba}\log n);
  • If it exists \epsilon>0, makes f (n) = \ Omega (n ^ {\ log_ba + \ epsilon}), and af (n / b) \ leq cf (n)holds, which cis a constant, nis a large enough number, then T(n)=\Theta (f(n)).

Let's also look at an example problem.

Example 2:T(n)=3T(n/4)+n\log n

Similarly, where a=3, b=4, and f(n)=n\log n. Compare n^{\log_4 3}and n\log neasy to see just \ log_43 + \ epsilon \ leq 1, there n\log n=\Omega(n^{\log_43+\epsilon}). Belongs to the third situation, therefore T(n)=\Theta(n\log n).

 

2. Akra-Bazzi theorem

 

Although the main theorem is very powerful and easy to apply, not all recursive relations can be used to find the complexity of the final asymptotic representation. A more generalized conclusion is the Akra-Bazzi theorem given by two Lebanese mathematicians Mohamad Akra and Louay Bazzi (both are also MIT alumni) in 1998 and later named after them. The formal formulation of the theorem is as follows:

Consider T(x)=g(x)+\sum ^k_{i=1}a_iT(b_ix+h_i(x)), for\ x\geq x_0the recursive form,

in case:

  • For all i, a_iand b_iit is a constant, wherein a_i>0, 0<b_i<1;
  • |g(x)|\in O(x^c), Which cis a constant;
  • For all i, |h_i(x)|\in O(\frac{x}{(\log x)^2});
  • x_0Is a constant

Then there is

T(x)\in \Theta(x^p(1+\int_{1}^{x}\frac{g(u)}{u^{p+1}}du))

Among them, pmeet  \sum_{i=1}^{k}a_ib_i^p=1.

 

How to apply the Akra-Bazzi theorem? Let's look at a few sample questions.

Example 3:T(n)=\frac{7}{4}T(\frac{1}{2}n)+T(\frac{3}{4}n)+n^2, for\ n\geq3

First, find the one that satisfies the condition p. Obviously \frac{7}{4}(\frac{1}{2})^p+(\frac{3}{4})^p=1, the pvalue 2 that makes it true is obvious . Then apply the above formula to get:

T(x)\in \Theta(x^2(1+\int_{1}^{x}\frac{u^2}{u^3}du))=\Theta(x^2\log x)

 

Example 4:, T(n)=\frac{1}{4}T(\frac{3}{4}n)+\frac{3}{4}T(\frac{1}{4}n)+1where n is a very large number

Obviously, the p-value that satisfies the condition is equal to 0, so there is

T(x)\in \Theta(x^0(1+\int_{1}^{x}\frac{1}{u}du))=\Theta(\log x)

 

Example 5:, T(n)=T(\frac{2}{7}n)+T(\frac{3}{7}n)+T(\frac{6}{7}n)+n^2where n is a very large number

It can be calculated that the p-value that satisfies the condition is equal to 2, so there is

T(x)\in \Theta(x^2(1+\int_{1}^{x}\frac{u^2}{u^3}du))=\Theta(x^2\log x)

Note that the p value does not necessarily need to be an integer, for example, it \log 3is also completely possible.



[End of this article]

 

Guess you like

Origin blog.csdn.net/baimafujinji/article/details/6470772