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 the recursive form,
- If , then ;
- If , then ;
- If , then .
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:
Apply the above formula, where a=1, b=3/2, and d=0, ie . Therefore, available .
The real version of the main theorem is given below:
Consider the recursive form,
- If it exists , so , then ;
- If , then ;
- If it exists , makes , and holds, which is a constant, is a large enough number, then .
Let's also look at an example problem.
Example 2:
Similarly, where a=3, b=4, and . Compare and easy to see just , there . Belongs to the third situation, therefore .
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 the recursive form,
in case:
- For all , and it is a constant, wherein , ;
- , Which is a constant;
- For all , ;
- Is a constant
Then there is
Among them, meet .
How to apply the Akra-Bazzi theorem? Let's look at a few sample questions.
Example 3:
First, find the one that satisfies the condition . Obviously , the value 2 that makes it true is obvious . Then apply the above formula to get:
Example 4:, where n is a very large number
Obviously, the p-value that satisfies the condition is equal to 0, so there is
Example 5:, where 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
Note that the p value does not necessarily need to be an integer, for example, it is also completely possible.
[End of this article]