Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing...
Transcript of Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing...
![Page 1: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/1.jpg)
Comparing Functions
![Page 2: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/2.jpg)
Notes on Notation
N = 0,1,2,3, ... N+ = 1,2,3,4, ... R = Set of RealsR+ = Set of Positive RealsR* = R+ U 0
![Page 3: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/3.jpg)
Comparing f(n) and g(n)
Let f be a function from N to R.O(f) (Big O of f) is the set of all functions
g from N to R such that:1. There exists a real number c>02. AND there exists an n0 in NSuch that: g(n) ≤ ≤ cf(n) whenever n ≥ ≥ n0
![Page 4: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/4.jpg)
Notation and Pronunciation
Proper Notation: g ∈ O(f)
Also Seen: g = O(f)“g is oh of f”
![Page 5: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/5.jpg)
Big Omega
Let f be a function from N to R.ΩΩ(f) (Big ΩΩ of f) is the set of all functions
g from N to R such that:1. There exists a real number c>02. AND there exists an n0 in NSuch that: g(n) ≥ ≥ cf(n) whenever n ≥ ≥ n0
![Page 6: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/6.jpg)
Big Theta
ΘΘ(f) = O(f) ∩∩ ΩΩ(f)
g ∈∈ ΘΘ(f)
“g is of Order f”
“g is Order f”
![Page 7: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/7.jpg)
Little o and Little Omega
o(f) = O(f) - Θ(f)
ω(f) = Ω(f) - Θ(f)
![Page 8: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/8.jpg)
English Interpretations
l O(f) - Functions that grow no faster than f
l Ω(f) - Functions that grow no slower than f
l Θ(f) - Functions that grow at the same rate as f
l o(f) - Functions that grow slower than f
l ω(f) - Functions that grow faster than f
![Page 9: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/9.jpg)
Limit Formulas
ifn
nn
c−>∞
=limg( )f( )
, for some c R∈ *
g f∈ Ω ( ) ifn
nn−>∞
= ∞limg( )f( ) n
nn
c−>∞
= >limg( )f( )
0or
g f∈ O( )
![Page 10: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/10.jpg)
More Limit Formulas
g f∈ Θ ( ) ifn
nn
c−>∞
=limg( )f( )
, for some c R∈ +
g o f∈ ( ) ifn
nn−>∞
=limg( )f( )
0
![Page 11: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/11.jpg)
The Last Limit Formula
g f∈ω ( ) ifn
nn−>∞
= ∞limg( )f( )
![Page 12: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/12.jpg)
Properties
l Transitivity– if f ∈ O(g) and g ∈ O(h) then f ∈ O(h)– Same holds for Θ , Ω, o, and ω
l Anti Symmetry (Sort of ...)– f ∈ O(g) if and only if g ∈ Ω(f)– May replace O with o and Ω with ω
![Page 13: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/13.jpg)
Some More Properties
l Symmetry– if f ∈ Θ(f), then g ∈ Θ(f)
l Reflexivity– f ∈ O(f)– Also true for Θ and Ω– Not True for o and ω
![Page 14: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/14.jpg)
And Even More Properties
l Big Theta is an equivalence relation– f R g if and only if f ∈ Θ(g)
l O(f+g) = O(max(f,g))– Also true for Θ and Ω
![Page 15: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/15.jpg)
Comparing Functions
![Page 16: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/16.jpg)
Notes on Notation
N = 0,1,2,3, ... N+ = 1,2,3,4, ... R = Set of RealsR+ = Set of Positive RealsR* = R+ U 0
![Page 17: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/17.jpg)
Comparing f(n) and g(n)
Let f be a function from N to R.O(f) (Big O of f) is the set of all functions
g from N to R such that:1. There exists a real number c>02. AND there exists an n0 in NSuch that: g(n) ≤ ≤ cf(n) whenever n ≥ ≥ n0
![Page 18: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/18.jpg)
Notation and Pronunciation
Proper Notation: g ∈ O(f)
Also Seen: g = O(f)“g is oh of f”
![Page 19: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/19.jpg)
Big Omega
Let f be a function from N to R.ΩΩ(f) (Big ΩΩ of f) is the set of all functions
g from N to R such that:1. There exists a real number c>02. AND there exists an n0 in NSuch that: g(n) ≥ ≥ cf(n) whenever n ≥ ≥ n0
![Page 20: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/20.jpg)
Big Theta
ΘΘ(f) = O(f) ∩∩ ΩΩ(f)
g ∈∈ ΘΘ(f)
“g is of Order f”
“g is Order f”
![Page 21: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/21.jpg)
Little o and Little Omega
o(f) = O(f) - Θ(f)
ω(f) = Ω(f) - Θ(f)
![Page 22: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/22.jpg)
English Interpretations
l O(f) - Functions that grow no faster than f
l Ω(f) - Functions that grow no slower than f
l Θ(f) - Functions that grow at the same rate as f
l o(f) - Functions that grow slower than f
l ω(f) - Functions that grow faster than f
![Page 23: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/23.jpg)
Limit Formulas
ifn
nn
c−>∞
=limg( )f( )
, for some c R∈ *
g f∈ Ω ( ) ifn
nn−>∞
= ∞limg( )f( ) n
nn
c−>∞
= >limg( )f( )
0or
g f∈ O( )
![Page 24: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/24.jpg)
More Limit Formulas
g f∈ Θ ( ) ifn
nn
c−>∞
=limg( )f( )
, for some c R∈ +
g o f∈ ( ) ifn
nn−>∞
=limg( )f( )
0
![Page 25: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/25.jpg)
The Last Limit Formula
g f∈ω ( ) ifn
nn−>∞
= ∞limg( )f( )
![Page 26: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/26.jpg)
Properties
l Transitivity– if f ∈ O(g) and g ∈ O(h) then f ∈ O(h)– Same holds for Θ , Ω, o, and ω
l Anti Symmetry (Sort of ...)– f ∈ O(g) if and only if g ∈ Ω(f)– May replace O with o and Ω with ω
![Page 27: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/27.jpg)
Some More Properties
l Symmetry– if f ∈ Θ(f), then g ∈ Θ(f)
l Reflexivity– f ∈ O(f)– Also true for Θ and Ω– Not True for o and ω
![Page 28: Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing f(n) and g(n) Let f be a function from N to R. O(f) (Big O of f) is the set of all](https://reader030.fdocuments.in/reader030/viewer/2022041016/5ec7719ae9b0871e1d6e9f26/html5/thumbnails/28.jpg)
And Even More Properties
l Big Theta is an equivalence relation– f R g if and only if f ∈ Θ(g)
l O(f+g) = O(max(f,g))– Also true for Θ and Ω