growth of function 2008. 1. 28 : 1 chapter 3. growth of function
TRANSCRIPT
Growth of function
한양대학교 정보보호 및 알고리즘 연구실
2008. 1. 28이재준
담당교수님 : 박희진 교수님1
Chapter 3. Growth of function
Contents of Table
1. Asymptotic notationO-notationΩ-notationΘ-notation
2. Asymptotically lager/smaller notation o-notation ω-notation
3. Relationship between this notations
2
• Asymptotic notation
- Which one is better algorithm for enough inputs?
we are studing asymptotic efficiency of algorithms ( size of the input in the limit, as the size of the inputs increases without
bound. )
3
1. Asymptotic notation
• O-notation
Asymptotically upper bound
- Definition
for all n, n ≥ n0 , 0 ≤ f(n) ≤ c g(n), the function f(n) is smaller or equal to g(n) to within constant factor.
4
1. Asymptotic notation
g(n) is asymptotically upper bound for f(n) g(n) is asymptotically upper bound for f(n)
• O-notation - Definition
O(g(n)) = f(n) : there exist positive constant c and n0 such that
0 ≤ f(n) ≤ c g(n) for all n ≥ n0
5
1. Asymptotic notation
f(n)
cg(n)
n0
n
• O-notation - f(n) = O(g(n)) means f(n) O(∈ g(n))
- means f(n) = θ(g(n)) implies f(n) = O(g(n)).
since θ-notation stronger notation than O-notation
6
1. Asymptotic notation
O(g(n))
f(n)
))(())(( ngOng
• O-notation Example
, ( )
Use the definition of O-notation to prove the following property.
, ( )
Use the definition of O-notation to prove the following property.
bannf )(
)()( 2nOnf
0a
1. Asymptotic notation
• O-notation Solution to example To show that , we need to find c and n0
For maximize value of , we make n0 = 1
Thus, c=a+\b\ and, n0 = 1 (because c is positive contant)
1. Asymptotic notation
cn
b
n
a
cnban
2
2
0
0
2n
b
n
a
20 cnban
cba ||0
• Ω-notation
Asymptotically lower bound
- Definition
for all n, n ≥ n0 , 0≤ c g(n) ≤ f(n) , the function f(n) is larger or equal to g(n) to within constant factor.
9
1. Asymptotic notation
g(n) is asymptotically lower bound for f(n) g(n) is asymptotically lower bound for f(n)
• Ω-notation - Definition
Ω (g(n)) = f(n) : there exist positive constant c and n0 such that
0 ≤ c g(n) ≤ f(n) for all n ≥ n0
10
1. Asymptotic notation
n0
cg(n)
f(n)
n
g(n) is asymptotically tight bound for f(n) g(n) is asymptotically tight bound for f(n)
• θ-notation
Asymptotically tight bound
- Definition
for all n, n ≥ n0 , 0≤ c1g(n) ≤ f(n) ≤ c2g(n), the function f(n) is equal to g(n) to within constant factor.
11
1. Asymptotic notation
• θ-notation - Definition
θ(g(n)) = f(n) : there exist positive constant c1, c2 and n0 such that
0 ≤ c1 g(n) ≤ f(n) ≤ c2 g(n) for all n ≥ n0
12
1. Asymptotic notation
c1g(n)
n0
f(n)
c2g(n)
n
• θ-notation - f(n) = θ(g(n)) means f(n) Θ(∈ g(n))
- Definition of θ(g(n)) requires that every member f(n) ∈Θ(g(n)) be asymptotically nonnegative (=asymptotically positive)
13
1. Asymptotic notation
θ(g(n)) f(n)
f(n)
n0
• θ-notation Example
1. Asymptotic notation
,
Use the definition of θ-notation to prove the following property.
,
Use the definition of θ-notation to prove the following property.
nnnf 32
1)( 2
)()( 2nnf
• θ-notation Solution to example
1. Asymptotic notation
221
22
221
3
2
10
32
10
cn
c
ncnnnc
nc
3
2
10 1
When n0=6 then c1 ≤ 0 c1 need to be positive constant so n0=6 is wrong.When n0=7 then c1 ≤ 1/14
(n0=7)14
114
10
1
1
c
c
2
3
2
1c
n
When n0=1 then ≤ 1/2n
3
2
1
2
12 c (n0=1)
thus, (n0=7)2
12 c
14
11 c
• θ-notation Example
1. Asymptotic notation
,
Use the definition of θ-notation to prove the following property.
,
Use the definition of θ-notation to prove the following property.
36)( nnf
)()( 2nnf
Thus, Thus,
• θ-notation Solution to example To show that , we need to find c1 , c2 and n0
so,
1. Asymptotic notation
n
c
n
c 21 6
22
321 6 ncnnc
n
c26
the more value of n is larger, the more value of is smaller
So, value of will be smaller than 6.
n
c2
n
c2
)()( 2nnf
• Theorem 3.1
• Relationship
18
1. Asymptotic notation
For any two functions f(n) and g(n), we have f(n) = Θ(g(n)) if and only if f(n) = O(g(n)) and f(n) = Ω(g(n)).For any two functions f(n) and g(n), we have f(n) = Θ(g(n)) if and only if f(n) = O(g(n)) and f(n) = Ω(g(n)).
θ(g(n))
O(g(n)) Ω(g(n))
19
1. Asymptotic notation
• Asymptotic notation in equations and inequalities
- Stands alone on the right-hand side of an equation
)( 2nOn equal sign to mean set
membershipn ∈ O(n2)
equal sign to mean set membership
n ∈ O(n2)
20
1. Asymptotic notation
• Asymptotic notation in equations and inequalities
- Asymptotic notation appears in a formula
)(2132 22 nnnn
)(2132 22 nfnnn
interpret is as standing for some anonymous function
f(n) ∈ Θ(n)
interpret is as standing for some anonymous function
f(n) ∈ Θ(n)
)(13 nn
)13)(( nnf
21
1. Asymptotic notation
• Asymptotic notation in equations and inequalities
- Asymptotic notation appears in a formula
There is no point in specifying all lower-order terms exactly
)()2/(2)( nnTnT
Eliminate inessential detail and clutter
Eliminate inessential detail and clutter
22
1. Asymptotic notation
• Asymptotic notation in equations and inequalities
- Number of anonymous functions
Number of anonymous functions
Number of anonymous functions
Number of times the asymptotic
notation
Number of times the asymptotic
notation
)(...)2()1()(1
nOOOiOn
i
)(nO
23
1. Asymptotic notation
• Asymptotic notation in equations and inequalities
- Asymptotic notation appears in left-hand side of an
equation
right-hand side of an equation provides a coarser level of detail than the left-hand side.
)()(2 22 nnn
There is a way to choose the anonymous functions on the right of the equal sign to make the equation valid.
There is a way to choose the anonymous functions on the right of the equal sign to make the equation valid.
)()(2 2 ngnfn
24
1. Asymptotic notation
• Asymptotic notation in equations and inequalities
- A number of such relationships can be chained together
)(2132 22 nnnn
)( 2n
f(n) ∈ Θ(n)f(n) ∈ Θ(n)
)(2132 22 nfnnn
g(n) ∈ Θ(n)g(n) ∈ Θ(n)
)()(2 2 nhngn h(n) ∈ Θ (n2)h(n) ∈ Θ (n2)
f(n) is asymptotically smaller than g(n) f(n) is asymptotically smaller than g(n)
• o-notation
Asymptotically smaller - Definition
for all n, n ≥ n0 , any positive constant c, c>0, 0 ≤ f(n)< cg(n), the function f(n) is smaller to g(n) to within constant factor.
25
2. Asymptotically larger/smaller notation
26
2. Asymptotically larger/smaller notation
• o-notation - Definition
o(g(n)) = f(n) : for any positive constant c>0, there exist a constant n0 >0 such that 0 ≤ f(n) < cg(n) for all n ≥ n0
f(n)
o(g(n))
n0
• o-notation - We use o-notation to denote an upper bound that is not
asymptotically tight.
-
this limit shows the function f(n) becomes insignificant relative to g(n) as n approaches infinity
27
2. Asymptotically larger/smaller notation
0)(
)(lim
ng
nf
n
• o-notation Example
1. Asymptotic notation
Use the definition of o-notation to prove the following property.
f(n) = o(n2)
Use the definition of o-notation to prove the following property.
f(n) = o(n2)
nnf 2)(
29
2. Asymptotically larger/smaller notation
• o-notation Solution to example
2n = o(n2)
If f(n) = o((g(n)) then
0)(
)(lim
ng
nf
n
f(n) is asymptotically larger than g(n) f(n) is asymptotically larger than g(n)
• ω -notation
Asymptotically larger - Definition
for all n, n ≥ n0 , any positive constant c, c>0, 0 ≤ cg(n) < f(n), the function f(n) is larger to g(n) to within constant factor.
30
2. Asymptotically larger/smaller notation
31
2. Asymptotically larger/smaller notation
• ω-notation - Definition
ω(g(n)) = f(n) : for any positive constant c>0, there exist a constant n0 >0 such that 0 ≤ cg(n) < f(n) for all n ≥ n0
f(n)
ω(g(n))
• ω -notation - We use ω-notation to denote a lower bound that is not
asymptotically tight.
- f(n) ω(∈ g(n)) if and only if g(n) ∈ o(f(n)).
-
if the limit exists. That is, f(n) becomes arbitrarily large relative to g(n) as n approaches infinity.
32
2. Asymptotically larger/smaller notation
)(
)(lim ng
nf
n
33
2. Asymptotically larger/smaller notation
• ω -notation Example
Use the definition of o-notation to prove the following property.
f(n) = ω(n)
Use the definition of o-notation to prove the following property.
f(n) = ω(n)
2)(
2nnf
34
2. Asymptotically larger/smaller notation
• ω -notation Solution to example
=ω(n)
If f(n) = ω((g(n)) then
2n
)(
)(lim ng
nf
n
35
3. Relationship between this notations
f(n)
O(g(n))
o(g(n))
ω(g(n))
Ω(g(n))
θ(g(n))
O(g(n)) Ω(g(n))
ω(g(n)) o(g(n))
36
3. Relationship between this notations
f(n)
O(g(n))
o(g(n))
ω(g(n))
Ω(g(n))
• Transitivity
• Transpose symmetry
f(n) = Θ(g(n)) and g(n) = Θ(h(n)) imply f(n) = Θ(h(n)) ,f(n) = O(g(n)) and g(n) = O(h(n)) imply f(n) = O(h(n)) , f(n) = Ω(g(n)) and g(n) = Ω(h(n)) imply f(n) = Ω(h(n)) ,f(n) = o(g(n)) and g(n) = o(h(n)) imply f(n) = o(h(n)) ,f(n) = ω(g(n)) and g(n) = ω(h(n)) imply f(n) = ω(h(n)).
f(n) = O(g(n)) if and only if g(n) = Ω(f(n)),f(n) = o(g(n)) if and only if g(n) = ω(f(n)).
37
3. Relationship between this notations
• Reflexivity
f(n) = Θ(f(n))f(n) = O(f(n))f(n) = Ω(f(n))
• Symmetry
f(n) = Θ(g(n)) if and only if g(n) = Θ(f(n)).
θ(g(n))
O(g(n)) Ω(g(n))
38
4. Question and Answer
Q&
A