Professional Documents
Culture Documents
4 Growth Functions Aeds I
4 Growth Functions Aeds I
4 Growth Functions Aeds I
Notation properties
Home Work
Growth of functions
bruno.ps@ufop.edu.br
Lectures are based courses from MIT, AEDS II UFMG, ED UFBA, ED Unicamp, PAA UESC,
and my knowledge about the subject.
1/19
Bruno P. dos Santos Growth of functions
Growth of functions
Notation properties
Home Work
Content
1 Growth of functions
2 Notation properties
3 Home Work
2/19
Bruno P. dos Santos Growth of functions
Growth of functions
Notation properties
Home Work
Content
1 Growth of functions
2 Notation properties
3 Home Work
2/19
Bruno P. dos Santos Growth of functions
Growth of functions
Notation properties
Home Work
Content
1 Growth of functions
2 Notation properties
3 Home Work
2/19
Bruno P. dos Santos Growth of functions
Asymptotic Notation
O-notation
Growth of functions
Ω-notation
Notation properties
Θ-notation
Home Work
o-notation
ω-notation
3/19
Bruno P. dos Santos Growth of functions
Asymptotic Notation
O-notation
Growth of functions
Ω-notation
Notation properties
Θ-notation
Home Work
o-notation
ω-notation
O-notation
O(g (n)) = {f (n) : there exist positive constants c and n0 such that
0 ≤ f (n) ≤ c · g (n) for all n ≥ n0 }
I.e., if f (n) ∈ O(g (n)) means that f (n) grows at most as fast as g (n).
5/19
Bruno P. dos Santos Growth of functions
Asymptotic Notation
O-notation
Growth of functions
Ω-notation
Notation properties
Θ-notation
Home Work
o-notation
ω-notation
O-notation: example
n2 + 5n ∈ O(n2 ) or we can write n2 + 5n = O(n2 )
We want:
• 0 ≤ n2 + 5n ≤ cn2 for all n ≥ n0
• 5n ≥ (c − 1)n2 , then c > 1
if c = 2 for instance:
• 5n ≤ n2
• then, n0 = 5
6/19
Bruno P. dos Santos Growth of functions
Asymptotic Notation
O-notation
Growth of functions
Ω-notation
Notation properties
Θ-notation
Home Work
o-notation
ω-notation
O-notation: example
n2 + 5n ∈ O(n2 ) or we can write n2 + 5n = O(n2 )
We want:
• 0 ≤ n2 + 5n ≤ cn2 for all n ≥ n0
• 5n ≥ (c − 1)n2 , then c > 1
if c = 2 for instance:
• 5n ≤ n2
• then, n0 = 5
6/19
Bruno P. dos Santos Growth of functions
Asymptotic Notation
O-notation
Growth of functions
Ω-notation
Notation properties
Θ-notation
Home Work
o-notation
ω-notation
O-notation: example
n2 + 5n ∈ O(n2 ) or we can write n2 + 5n = O(n2 )
We want:
• 0 ≤ n2 + 5n ≤ cn2 for all n ≥ n0
• 5n ≥ (c − 1)n2 , then c > 1
if c = 2 for instance:
• 5n ≤ n2
• then, n0 = 5
6/19
Bruno P. dos Santos Growth of functions
Asymptotic Notation
O-notation
Growth of functions
Ω-notation
Notation properties
Θ-notation
Home Work
o-notation
ω-notation
O-notation: example
n2 + 5n ∈ O(n2 ) or we can write n2 + 5n = O(n2 )
We want:
• 0 ≤ n2 + 5n ≤ cn2 for all n ≥ n0
• 5n ≥ (c − 1)n2 , then c > 1
if c = 2 for instance:
• 5n ≤ n2
• then, n0 = 5
6/19
Bruno P. dos Santos Growth of functions
Asymptotic Notation
O-notation
Growth of functions
Ω-notation
Notation properties
Θ-notation
Home Work
o-notation
ω-notation
O-notation: example
n2 + 5n ∈ O(n2 ) or we can write n2 + 5n = O(n2 )
We want:
• 0 ≤ n2 + 5n ≤ cn2 for all n ≥ n0
• 5n ≥ (c − 1)n2 , then c > 1
if c = 2 for instance:
• 5n ≤ n2
• then, n0 = 5
6/19
Bruno P. dos Santos Growth of functions
Asymptotic Notation
O-notation
Growth of functions
Ω-notation
Notation properties
Θ-notation
Home Work
o-notation
ω-notation
Ω-notation
Ω(g (n)) = {f (n) : there exist positive constants c and n0 such that
0 ≤ c · g (n) ≤ f (n) for all n ≥ n0 }
I.e., if f (n) ∈ Ω(g (n)) means that f (n) grows at least as slowly as g (n)
7/19
Bruno P. dos Santos Growth of functions
Asymptotic Notation
O-notation
Growth of functions
Ω-notation
Notation properties
Θ-notation
Home Work
o-notation
ω-notation
Ω-notation: example
n3 − n2 ∈ Ω(n3 )
We want:
• n3 − n2 ≥ cn3 ≥ 0 for all n ≥ n0
• n2 ≤ (1 − c)n3 , or simply: 1 ≤ (1 − c)n
1
if c = 2 for instance:
• 1 ≤ 12 n
• then, n0 = 2
8/19
Bruno P. dos Santos Growth of functions
Asymptotic Notation
O-notation
Growth of functions
Ω-notation
Notation properties
Θ-notation
Home Work
o-notation
ω-notation
Ω-notation: example
n3 − n2 ∈ Ω(n3 )
We want:
• n3 − n2 ≥ cn3 ≥ 0 for all n ≥ n0
• n2 ≤ (1 − c)n3 , or simply: 1 ≤ (1 − c)n
1
if c = 2 for instance:
• 1 ≤ 12 n
• then, n0 = 2
8/19
Bruno P. dos Santos Growth of functions
Asymptotic Notation
O-notation
Growth of functions
Ω-notation
Notation properties
Θ-notation
Home Work
o-notation
ω-notation
Ω-notation: example
n3 − n2 ∈ Ω(n3 )
We want:
• n3 − n2 ≥ cn3 ≥ 0 for all n ≥ n0
• n2 ≤ (1 − c)n3 , or simply: 1 ≤ (1 − c)n
1
if c = 2 for instance:
• 1 ≤ 12 n
• then, n0 = 2
8/19
Bruno P. dos Santos Growth of functions
Asymptotic Notation
O-notation
Growth of functions
Ω-notation
Notation properties
Θ-notation
Home Work
o-notation
ω-notation
Ω-notation: example
n3 − n2 ∈ Ω(n3 )
We want:
• n3 − n2 ≥ cn3 ≥ 0 for all n ≥ n0
• n2 ≤ (1 − c)n3 , or simply: 1 ≤ (1 − c)n
1
if c = 2 for instance:
• 1 ≤ 12 n
• then, n0 = 2
8/19
Bruno P. dos Santos Growth of functions
Asymptotic Notation
O-notation
Growth of functions
Ω-notation
Notation properties
Θ-notation
Home Work
o-notation
ω-notation
Ω-notation: example
n3 − n2 ∈ Ω(n3 )
We want:
• n3 − n2 ≥ cn3 ≥ 0 for all n ≥ n0
• n2 ≤ (1 − c)n3 , or simply: 1 ≤ (1 − c)n
1
if c = 2 for instance:
• 1 ≤ 12 n
• then, n0 = 2
8/19
Bruno P. dos Santos Growth of functions
Asymptotic Notation
O-notation
Growth of functions
Ω-notation
Notation properties
Θ-notation
Home Work
o-notation
ω-notation
Θ-notation
Θ(g (n)) = {f (n) : there exist positive constants c1 , c2 and n0 such that
0 ≤ c1 · g (n) ≤ f (n) ≤ c2 · g (n) for all n ≥ n0 }
I.e., if f (n) ∈ Θ(g (n)) means that f (n) can be “sandwiched” between
c1 g (n) and c2 g (n). Growing as quickly as g (n).
• Asymptotically tight
bound (limite restrito)
• Pronounced “Theta of g
of n”
9/19
Bruno P. dos Santos Growth of functions
Asymptotic Notation
O-notation
Growth of functions
Ω-notation
Notation properties
Θ-notation
Home Work
o-notation
ω-notation
Θ-notation: example
2n2 + 2n ∈ Θ(n2 )
We want:
• 0 ≤ c1 n2 ≤ 2n2 + 2 ≤ c2 n2 for all n ≥ n0
• For one hand:
• 2n ≤ (2 − c1 )n2 , or simply: 2 ≤ (2 − c1 )n
• Taking c1 = 1, for instance
• then n0 = 2
• For the other hand:
• 2n ≤ (c2 − 2)n2 , or simply: 2 ≤ (c2 − 2)n
• Taking c2 = 3, for instance
• ten n0 = 2
Θ-notation: example
2n2 + 2n ∈ Θ(n2 )
We want:
• 0 ≤ c1 n2 ≤ 2n2 + 2 ≤ c2 n2 for all n ≥ n0
• For one hand:
• 2n ≤ (2 − c1 )n2 , or simply: 2 ≤ (2 − c1 )n
• Taking c1 = 1, for instance
• then n0 = 2
• For the other hand:
• 2n ≤ (c2 − 2)n2 , or simply: 2 ≤ (c2 − 2)n
• Taking c2 = 3, for instance
• ten n0 = 2
Θ-notation: example
2n2 + 2n ∈ Θ(n2 )
We want:
• 0 ≤ c1 n2 ≤ 2n2 + 2 ≤ c2 n2 for all n ≥ n0
• For one hand:
• 2n ≤ (2 − c1 )n2 , or simply: 2 ≤ (2 − c1 )n
• Taking c1 = 1, for instance
• then n0 = 2
• For the other hand:
• 2n ≤ (c2 − 2)n2 , or simply: 2 ≤ (c2 − 2)n
• Taking c2 = 3, for instance
• ten n0 = 2
Θ-notation: example
2n2 + 2n ∈ Θ(n2 )
We want:
• 0 ≤ c1 n2 ≤ 2n2 + 2 ≤ c2 n2 for all n ≥ n0
• For one hand:
• 2n ≤ (2 − c1 )n2 , or simply: 2 ≤ (2 − c1 )n
• Taking c1 = 1, for instance
• then n0 = 2
• For the other hand:
• 2n ≤ (c2 − 2)n2 , or simply: 2 ≤ (c2 − 2)n
• Taking c2 = 3, for instance
• ten n0 = 2
Θ-notation: example
2n2 + 2n ∈ Θ(n2 )
We want:
• 0 ≤ c1 n2 ≤ 2n2 + 2 ≤ c2 n2 for all n ≥ n0
• For one hand:
• 2n ≤ (2 − c1 )n2 , or simply: 2 ≤ (2 − c1 )n
• Taking c1 = 1, for instance
• then n0 = 2
• For the other hand:
• 2n ≤ (c2 − 2)n2 , or simply: 2 ≤ (c2 − 2)n
• Taking c2 = 3, for instance
• ten n0 = 2
Θ-notation: example
2n2 + 2n ∈ Θ(n2 )
We want:
• 0 ≤ c1 n2 ≤ 2n2 + 2 ≤ c2 n2 for all n ≥ n0
• For one hand:
• 2n ≤ (2 − c1 )n2 , or simply: 2 ≤ (2 − c1 )n
• Taking c1 = 1, for instance
• then n0 = 2
• For the other hand:
• 2n ≤ (c2 − 2)n2 , or simply: 2 ≤ (c2 − 2)n
• Taking c2 = 3, for instance
• ten n0 = 2
Θ-notation: example
2n2 + 2n ∈ Θ(n2 )
We want:
• 0 ≤ c1 n2 ≤ 2n2 + 2 ≤ c2 n2 for all n ≥ n0
• For one hand:
• 2n ≤ (2 − c1 )n2 , or simply: 2 ≤ (2 − c1 )n
• Taking c1 = 1, for instance
• then n0 = 2
• For the other hand:
• 2n ≤ (c2 − 2)n2 , or simply: 2 ≤ (c2 − 2)n
• Taking c2 = 3, for instance
• ten n0 = 2
Θ-notation: example
2n2 + 2n ∈ Θ(n2 )
We want:
• 0 ≤ c1 n2 ≤ 2n2 + 2 ≤ c2 n2 for all n ≥ n0
• For one hand:
• 2n ≤ (2 − c1 )n2 , or simply: 2 ≤ (2 − c1 )n
• Taking c1 = 1, for instance
• then n0 = 2
• For the other hand:
• 2n ≤ (c2 − 2)n2 , or simply: 2 ≤ (c2 − 2)n
• Taking c2 = 3, for instance
• ten n0 = 2
Θ-notation: example
2n2 + 2n ∈ Θ(n2 )
We want:
• 0 ≤ c1 n2 ≤ 2n2 + 2 ≤ c2 n2 for all n ≥ n0
• For one hand:
• 2n ≤ (2 − c1 )n2 , or simply: 2 ≤ (2 − c1 )n
• Taking c1 = 1, for instance
• then n0 = 2
• For the other hand:
• 2n ≤ (c2 − 2)n2 , or simply: 2 ≤ (c2 − 2)n
• Taking c2 = 3, for instance
• ten n0 = 2
Θ-notation: example
2n2 + 2n ∈ Θ(n2 )
We want:
• 0 ≤ c1 n2 ≤ 2n2 + 2 ≤ c2 n2 for all n ≥ n0
• For one hand:
• 2n ≤ (2 − c1 )n2 , or simply: 2 ≤ (2 − c1 )n
• Taking c1 = 1, for instance
• then n0 = 2
• For the other hand:
• 2n ≤ (c2 − 2)n2 , or simply: 2 ≤ (c2 − 2)n
• Taking c2 = 3, for instance
• ten n0 = 2
o-notation
o(g (n)) = {f (n) : for any positive constant c > 0, there exist a
constant n0 such that 0 ≤ f (n) < cg (n) for all n ≥ n0 }
I.e., if f (n) ∈ o(g (n)) means that f (n) grows more slowly than g (n).
o-notation: example
100n2 ∈ o(n3 )
We want: for all c > 0∃n0 > 0 that satisfy the definition.
• 100n2 < cn3 , or simply: 100 < cn
• we can take: n0 = 100
c +1
11/19
Bruno P. dos Santos Growth of functions
Asymptotic Notation
O-notation
Growth of functions
Ω-notation
Notation properties
Θ-notation
Home Work
o-notation
ω-notation
o-notation
o(g (n)) = {f (n) : for any positive constant c > 0, there exist a
constant n0 such that 0 ≤ f (n) < cg (n) for all n ≥ n0 }
I.e., if f (n) ∈ o(g (n)) means that f (n) grows more slowly than g (n).
o-notation: example
100n2 ∈ o(n3 )
We want: for all c > 0∃n0 > 0 that satisfy the definition.
• 100n2 < cn3 , or simply: 100 < cn
• we can take: n0 = 100
c +1
11/19
Bruno P. dos Santos Growth of functions
Asymptotic Notation
O-notation
Growth of functions
Ω-notation
Notation properties
Θ-notation
Home Work
o-notation
ω-notation
ω-notation
ω(g (n)) = {f (n) : for any positive constant c > 0, there exist a
constant n0 such that 0 ≤ cg (n) < f (n) for all n ≥ n0 }
I.e., if f (n) ∈ o(g (n)) means that f (n) grows faster than g (n).
ω-notation: example
n3
1000 ∈ ω(n2 )
We want: for all c > 0∃n0 > 0 that satisfy the definition.
n3 n
• > cn2 , or simply: 1000
1000 <c
• we can take: n0 = 1000c + 1
12/19
Bruno P. dos Santos Growth of functions
Asymptotic Notation
O-notation
Growth of functions
Ω-notation
Notation properties
Θ-notation
Home Work
o-notation
ω-notation
ω-notation
ω(g (n)) = {f (n) : for any positive constant c > 0, there exist a
constant n0 such that 0 ≤ cg (n) < f (n) for all n ≥ n0 }
I.e., if f (n) ∈ o(g (n)) means that f (n) grows faster than g (n).
ω-notation: example
n3
1000 ∈ ω(n2 )
We want: for all c > 0∃n0 > 0 that satisfy the definition.
n3 n
• > cn2 , or simply: 1000
1000 <c
• we can take: n0 = 1000c + 1
12/19
Bruno P. dos Santos Growth of functions
Definition
Comparing functions
Growth of functions
Transitivity
Notation properties
Reflexivity
Home Work
Symmetry
An simple analogy
f (n)
• f (n) ∈ o(g (n)) if limn→∞ g (n) =0
• f (n) ∈ O(g (n)) if limn→∞ gf (n)
(n) ≥0
f (n)
• f (n) ∈ Θ(g (n)) if 0 < limn→∞ g (n) <∞
f (n)
• f (n) ∈ Ω(g (n)) if 0 < limn→∞ g (n) ≤∞
f (n)
• f (n) ∈ ω(g (n)) if limn→∞ g (n) =∞
13/19
Bruno P. dos Santos Growth of functions
Definition
Comparing functions
Growth of functions
Transitivity
Notation properties
Reflexivity
Home Work
Symmetry
An simple analogy
14/19
Bruno P. dos Santos Growth of functions
Definition
Comparing functions
Growth of functions
Transitivity
Notation properties
Reflexivity
Home Work
Symmetry
An simple analogy
15/19
Bruno P. dos Santos Growth of functions
Definition
Comparing functions
Growth of functions
Transitivity
Notation properties
Reflexivity
Home Work
Symmetry
An simple analogy
• f (n) ∈
/ o(f (n))
• f (n) ∈
/ ω(f (n))
16/19
Bruno P. dos Santos Growth of functions
Definition
Comparing functions
Growth of functions
Transitivity
Notation properties
Reflexivity
Home Work
Symmetry
An simple analogy
• Symmetry
• f (n) ∈ Θ(g (n)) iff (if and only if) g (n) ∈ Θ(f (n))
• Transpose Symmetry
• f (n) ∈ O(g (n)) iff g (n) ∈ Ω(f (n))
• f (n) ∈ o(g (n)) iff g (n) ∈ ω(f (n))
17/19
Bruno P. dos Santos Growth of functions
Definition
Comparing functions
Growth of functions
Transitivity
Notation properties
Reflexivity
Home Work
Symmetry
An simple analogy
Draw an analogy
• f (n) ∈ o(g (n)) is like a < b
• f (n) ∈ O(g (n)) is like a ≤ b
• f (n) ∈ Θ(g (n)) is like a = b
• f (n) ∈ Ω(g (n)) is like a ≥ b
• f (n) ∈ ω(g (n)) is like a > b
18/19
Bruno P. dos Santos Growth of functions
Growth of functions
Notation properties
Home Work
CLRS book:
• Chapter 3
• Pay attention on 3.2
• Exercises: 3.1-1, 3.1-2, 3.1-3, 3.1-4, 3.1-7
• Problems: 3-1, 3-2, 3-3a, 3-4: a,b,f.
19/19
Bruno P. dos Santos Growth of functions