0% found this document useful (0 votes)
42 views

Asymptotic Notation & Review of Functions

This document provides an overview of asymptotic notation and complexity analysis. It defines common asymptotic notations like Θ, O, Ω, o, ω and explains what types of functions they describe. Specifically, it explains that Θ notation describes functions that have the same asymptotic growth rate, while O notation describes functions with equal or slower growth. Ω notation describes equal or faster growth. The document also gives examples of how to determine if a function is a member of a given asymptotic notation class and discusses the relationships between the different notations.
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Asymptotic Notation & Review of Functions

This document provides an overview of asymptotic notation and complexity analysis. It defines common asymptotic notations like Θ, O, Ω, o, ω and explains what types of functions they describe. Specifically, it explains that Θ notation describes functions that have the same asymptotic growth rate, while O notation describes functions with equal or slower growth. Ω notation describes equal or faster growth. The document also gives examples of how to determine if a function is a member of a given asymptotic notation class and discusses the relationships between the different notations.
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 17

Asymptotic

Asymptotic Notation
Notation &
&
Review
Review of
of Functions
Functions

B.H.M
@
CSE_SSIT

13SCS13, 2017
Asymptotic Complexity
 Running time of an algorithm as a function of
input size n for large n.
 Expressed using only the highest-order term in
the expression for the exact running time.
 Instead of exact running time, say (n2).
 Describes behavior of function in the limit.
 Written using Asymptotic Notation.

ymp - 2 13SCS13, 2017


Asymptotic Notation
 , O, , o, 
 Defined for functions over the natural numbers.
 Ex: f(n) = (n2).
 Describes how f(n) grows in comparison to n2.
 Define a set of functions; in practice used to compare
two function sizes.
 The notations describe different rate-of-growth
relations between the defining function and the
defined set of functions.

ymp - 3 13SCS13, 2017


-notation
For function g(n), we define (g(n)),
big-Theta of n, as the set:
(g(n)) = {f(n) :
 positive constants c1, c2, and n0,
such that n  n0,
we have 0  c1g(n)  f(n)  c2g(n)

}
Intuitively: Set of all functions that
have the same rate of growth as g(n).

g(n) is an asymptotically tight bound for f(n).

ymp - 4 13SCS13, 2017


-notation
For function g(n), we define (g(n)),
big-Theta of n, as the set:
(g(n)) = {f(n) :
 positive constants c1, c2, and n0,
such that n  n0,
we have 0  c1g(n)  f(n)  c2g(n)

}
Technically, f(n)  (g(n)).
Older usage, f(n) = (g(n)).
I’ll accept either…

f(n) and g(n) are nonnegative, for large n.


ymp - 5 13SCS13, 2017
Example
(g(n)) = {f(n) :  positive constants c1, c2, and n0,
such that n  n0, 0  c1g(n)  f(n)  c2g(n)}

 10n2 - 3n = (n2)
 What constants for n0, c1, and c2 will work?
 Make c1 a little smaller than the leading
coefficient, and c2 a little bigger.
 To compare orders of growth, look at the
leading term.
 Exercise: Prove that n2/2-3n= (n2)
ymp - 6 13SCS13, 2017
Example
(g(n)) = {f(n) :  positive constants c1, c2, and n0,
such that n  n0, 0  c1g(n)  f(n)  c2g(n)}

 Is 3n3  (n4) ??
 How about 22n (2n)??

ymp - 7 13SCS13, 2017


O-notation
For function g(n), we define O(g(n)),
big-O of n, as the set:
O(g(n)) = {f(n) :
 positive constants c and n0,
such that n  n0,
we have 0  f(n)  cg(n) }
Intuitively: Set of all functions
whose rate of growth is the same as
or lower than that of g(n).
g(n) is an asymptotic upper bound for f(n).
f(n) = (g(n))  f(n) = O(g(n)).
(g(n))  O(g(n)).
ymp - 8 13SCS13, 2017
Examples
O(g(n)) = {f(n) :  positive constants c and n0,
such that n  n0, we have 0  f(n)  cg(n) }

 Any linear function an + b is in O(n2). How?


 Show that 3n3=O(n4) for appropriate c and n0.

ymp - 9 13SCS13, 2017


 -notation
For function g(n), we define (g(n)),
big-Omega of n, as the set:
(g(n)) = {f(n) :
 positive constants c and n0,
such that n  n0,
we have 0  cg(n)  f(n)}
Intuitively: Set of all functions
whose rate of growth is the same
as or higher than that of g(n).
g(n) is an asymptotic lower bound for f(n).
f(n) = (g(n))  f(n) = (g(n)).
(g(n))  (g(n)).
ymp - 10 13SCS13, 2017
Example
(g(n)) = {f(n) :  positive constants c and n0, such
that n  n0, we have 0  cg(n)  f(n)}

 n = (lg n). Choose c and n0.

ymp - 11 13SCS13, 2017


Relations Between , O, 

ymp - 12 13SCS13, 2017


Relations Between , , O
Theorem
Theorem :: ForFor any
any two
two functions
functions g(n)
g(n) and
and f(n),
f(n),
f(n) == (g(n))
f(n) (g(n)) iff
iff
f(n)
f(n) == O(g(n))
O(g(n)) and f(n) == (g(n)).
and f(n) (g(n)).

 I.e., (g(n)) = O(g(n))  (g(n))

 In practice, asymptotically tight bounds are


obtained from asymptotic upper and lower bounds.

ymp - 13 13SCS13, 2017


Running Times
 “Running time is O(f(n))”  Worst case is O(f(n))
 O(f(n)) bound on the worst-case running time 
O(f(n)) bound on the running time of every input.
 (f(n)) bound on the worst-case running time 
(f(n)) bound on the running time of every input.
 “Running time is (f(n))”  Best case is (f(n))
 Can still say “Worst-case running time is (f(n))”
 Means worst-case running time is given by some
unspecified function g(n)  (f(n)).

ymp - 14 13SCS13, 2017


Asymptotic Notation in Equations
 Can use asymptotic notation in equations to
replace expressions containing lower-order terms.
 For example,
4n3 + 3n2 + 2n + 1 = 4n3 + 3n2 + (n)
= 4n3 + (n2) = (n3). How to interpret?
 In equations, (f(n)) always stands for an
anonymous function g(n)  (f(n))
 In the example above, (n2) stands for
3n2 + 2n + 1.

ymp - 15 13SCS13, 2017


o-notation
For a given function g(n), the set little-o:
o(g(n)) = {f(n):  c > 0,  n0 > 0 such that
 n  n0, we have 0  f(n) < cg(n)}.
f(n) becomes insignificant relative to g(n) as n
approaches infinity:
lim [f(n) / g(n)] = 0
n

g(n) is an upper bound for f(n) that is not


asymptotically tight.
Observe the difference in this definition from previous
ones. Why?
ymp - 16 13SCS13, 2017
 -notation
For a given function g(n), the set little-omega:

(g(n)) = {f(n):  c > 0,  n > 0 such that


0
 n  n0, we have 0  cg(n) < f(n)}.
f(n) becomes arbitrarily large relative to g(n) as n
approaches infinity:
lim [f(n) / g(n)] = .
n

g(n) is a lower bound for f(n) that is not


asymptotically tight.

ymp - 17 13SCS13, 2017

You might also like