03 - Inha Asymptotic Notations
03 - Inha Asymptotic Notations
Asymptotic Notations
Notations
Mathematical Model of Computation
Framework for Algorithmic Analysis
ymp - 2
Mathematical Model of Computation
Model of Computation specifies:
What operations in an algorithm is allowed
Cost (time) of each operation
ymp - 3
Computing running time in Model
Simple Statement
(1 step execution )
Arithmetic & logical operations.
Jumps & conditional jumps
Pointer instruction
Array operations (1D)
ymp - 4
More Complex Statement
(multistep execution)
A=B+C*D-F 3 steps
X=B[I]
A[I]=B[I] + C[I] 4 steps Y=C[I]
Z=X+Y
A[I]=Z
C = A[I,J] 4 steps
A’ [(I)*M + J] where m is the number of columns
ymp - 5
General Analysis Strategy T(n)
T(n)= n
-Max time taken by an algorithm to solve any instance of
size n.
-measures a goodness of an algorithm, i.e functional form
of T(n) is important (linear, cubic, quadratic, etc.)
-Significance of T(n) is independent of model/computer
we used for analysis because here the objective is to
characterize the algorithm not the machine
1.Function classification
ymp - 8
Asymptotic Notation
, O, , o,
ymp - 9
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 - 10
Examples
O(g(n)) = {f(n) : positive constants c and n0,
such that n n0, we have 0 f(n) cg(n) }
ymp - 11
-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 - 12
-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).
ymp - 13
-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)).
accept either notation…
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.
ymp - 15
Relations Between , O,
ymp - 16
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))
ymp - 17
Running Times
“Running time is O(f(n))” Worst case is O(f(n))
“Running time is (f(n))” Best case is (f(n))
ymp - 18
Comparison of Functions
fg ab
f (n) = O(g(n)) a b
f (n) = (g(n)) a b
f (n) = (g(n)) a = b
f (n) = o(g(n)) a < b
f (n) = (g(n)) a > b
ymp - 19
Properties
Transitivity
f(n) = (g(n)) & g(n) = (h(n)) f(n) = (h(n))
f(n) = O(g(n)) & g(n) = O(h(n)) f(n) = O(h(n))
f(n) = (g(n)) & g(n) = (h(n)) f(n) = (h(n))
f(n) = o (g(n)) & g(n) = o (h(n)) f(n) = o (h(n))
f(n) = (g(n)) & g(n) = (h(n)) f(n) = (h(n))
Reflexivity
f(n) = (f(n))
f(n) = O(f(n))
f(n) = (f(n))
ymp - 20
Properties
Symmetry
f(n) = (g(n)) iff g(n) = (f(n))
Complementarity
f(n) = O(g(n)) iff g(n) = (f(n))
f(n) = o(g(n)) iff g(n) = ((f(n))
ymp - 21
Growth of a function
Find the big oh for the following functions
f(n) = 3n + 5
f(n) = 27n2 + 16n + 25
f(n) = 3n3 + 4n
f(n) = 2n + 6n2 + 3n
f(n) = 5*2n + 3n +5
f(n) = 3*2n + 4n2 + 5n + 3
ymp - 22
Incorrect bounds
7n+5 ≠ O(1)
27n2 + 16n + 25 ≠ O(n)
5n3 + n2 + 3n + 2 ≠ O(n2)
ymp - 23
Find the big Omega for the following functions
ymp - 24
Incorrect bounds
7n+5 ≠ (n2)
5n2 + 4n +2 ≠ (n3)
3n3+ 5n2 +2n ≠ (n4)
ymp - 25
Find the Thetafor the following functions
ymp - 26
Incorrect bounds
7n+5 ≠ (1)
10n2+ 7 ≠ (n3)
5n+8 ≠ (n2)
ymp - 27
Video Lecture of the topic can be found at
ymp - 28