If you want to reprint, you need to specify the source: Http://blog.csdn.net/xiazdong
This paper summarizes the third chapter of the algorithm introduction, but it adds some additions to this chapter, and explains the problem with the introduction of the algorithm. I believe this article will give you a deeper understanding of the asymptotic notation.
I. Definition Introduction For a relatively simple algorithm, we can sometimes accurately analyze the complexity of the algorithm, such as the complexity of the algorithm is 5n^2+10n+6, but in fact, it is not necessary, because when n is large enough, you can ignore the lower order and the highest degree of the coefficients, so the "asymptotic complexity", and the " Asymptotic notation "to denote" asymptotic complexity ".
The asymptotic notation includes: (1) Θ (theta): tight-definite bounds. Equivalent to "=" (2) O (Greater Europe): upper bound. Equivalent to "<=" (3) O (Small Europe): the upper bound of the non-tight. Equivalent to "<" (4) Ω (large Omega): Nether. Equivalent to ">=" (5) Ω (small Omega): non-tight lower bound. Equivalent to ">"
Give the definition of these tokens:
Note for the definition: (1) The premise of these definitions is that f (n) and g (n) are asymptotically nonnegative, and asymptotic nonnegative means "when n tends to infinity, f (n) and g (n) are non-negative". (2) For definitions 4th and 5th, it is important to note that for any c.
The relationship of these 5 symbols is represented by a set theory:
As can be seen from the above figure: (1) if f (n) =θ (g (n)), then f (n) = O (g (n)) and f (n) =ω (g (n)). (2) if f (n) = O (g (n)), then f (n) = O (g (n)). (3) if f (n) =ω (g (n)), then f (n) =ω (g (n)). (4) if f (n) = O (g (n)), either f (n) = O (g (n)) or F (n) =θ (g (n)). (5) if f (n) =ω (g (n)), then either f (N) =ω (g (n)), or F (n) =θ (g (n)).
The reason is simple because: (1) if f (n) =θ (g (n)), then there must be c1,c2,n0 according to the definition, so that for any n>=n0, there is c1g (n) <=f (n) <=c2g (n), so there must be "c=c2,n0, which makes Arbitrary n>=n0, have f (n) <=CG (n) "" C=c1,n0, so that for any n>=n0, there is CG (n) <= f (N) "(2) if f (n) = O (g (n)), then according to the definition of arbitrary c , there are n0, so arbitrary n>=n0, all have f (n) <CG (n), so there must be "presence c,n0, so that for any n>=n0, there is f (n) <=CG (n)" (3) if f (n) =ω (g (n)), According to the definition must be for any C, there are n0, so that arbitrary n>=n0, have CG (n) < F (n), so there must be "existence c,n0, so for any n>=n0, there is CG (n) <= f (n)"
After understanding these definitions, a concept is given: The asymptotic notation represents a collection, such as O (N^2) represents a set, which can be n,1,n^2, so the most accurate use of these asymptotic notation should be "f (n) ∈o (g (n))", but it is generally written as "f (n) = O ( g (n)) ".
Give some examples: O (n^2) can be n,2n,1,2n^2 and so on. Θ (n^2) can be n^2,3n^2 and so on. Ω (n^2) can be n^3,n^10 and so on, but not n^2. Ω (n^2) can be n^2,n^3,n^10 and so on. O (n^2) can be n,1,3n and so on, but not n^2.
In general, we describe the complexity of the algorithm with O notation, for example, the complexity of Bellmanford is O (VE), indicating that for all inputs, the O (VE) is satisfied.
second, to judge the asymptotic relationship of two functions Here we give a very general method, called the "limit Method".
Seeing the method above, many people would ask "how do not O and Ω." ", the reason is simple, because if f (n) = O (g (n)), then either f (n) = O (g (n)), or F (n) =θ (g (n)).
Stirling Formula:
Also note: We in the proof, generally do not need to specify the value of N0, only need to prove that there must be n0. (like in the last few lines of the P27 page of the algorithmic introduction, he gives a very complex n0, which doesn't have to go into it.) )
Let's start with an example.
The first one.Derived from the introduction of the algorithm study questions 3-1.
a second questionDerived from the algorithm introduction 3.2-3.
a third questionDerived from the algorithm introduction 3.2-5.
Question Fourthis to design the function to meet certain conditions.
Question FifthAlso about designing a function, he is an introduction to algorithms study Questions 3-3 (b).
Finally, I want to give an introduction to the algorithm study questions 3-4, because this problem can be more clear concept of geographical clarity.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.