Comparing Functions - Baylor Universitycs.baylor.edu/~maurer/aida/courses/ordrnot.pdf · Comparing...

28
Comparing Functions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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 Ω