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

03 - Inha Asymptotic Notations

1. The document discusses mathematical models of computation and asymptotic notations for analyzing algorithms. 2. It explains that asymptotic notations like O, Ω, and Θ classify functions based on their growth rates and are used to identify the asymptotic behavior of algorithms as input size n approaches infinity. 3. The notations describe relationships between algorithm running times and simple functions like n, n^2, n^3, etc. to characterize how an algorithm's running time grows with n.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views

03 - Inha Asymptotic Notations

1. The document discusses mathematical models of computation and asymptotic notations for analyzing algorithms. 2. It explains that asymptotic notations like O, Ω, and Θ classify functions based on their growth rates and are used to identify the asymptotic behavior of algorithms as input size n approaches infinity. 3. The notations describe relationships between algorithm running times and simple functions like n, n^2, n^3, etc. to characterize how an algorithm's running time grows with n.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 28

Asymptotic

Asymptotic Notations
Notations
Mathematical Model of Computation
Framework for Algorithmic Analysis

Need of Mathematical Model

Real Computers Vs Mathematical Model

ymp - 2
Mathematical Model of Computation
Model of Computation specifies:
What operations in an algorithm is allowed
Cost (time) of each operation

Two components of Model


Processor (has defined instruction set)
Memory (collection of locations)

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

Running Time Calculations


To Add elements of two arrays of size n
ymp - 6
Asymptotic
Asymptotic Notations
Notations

Has two features

1.Function classification

2.Identify the behaviour as n ∞


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).

 Written using Asymptotic Notation.

ymp - 8
Asymptotic Notation
 , O, , o, 

 Defined for functions over the natural numbers.


 Ex: f(n) = (n2).
 Describes how f(n) grows in comparison to n2.

 The notations describe different rate-of-growth


relations between the defining function and the
defined set of functions.

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) }

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


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

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).

g(n) is an asymptotically tight bound for f(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…

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


ymp - 14
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.

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))

 In practice, asymptotically tight bounds are


obtained from asymptotic upper and lower bounds.

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
fg  ab

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

 f(n) = 27n2 + 16n


 f(n) = 4n3 + 2n + 3
 f(n) = 2n + 6n2 +3n
 f(n) = 5*2n + 3n +5

ymp - 24
Incorrect bounds
 7n+5 ≠ (n2)
 5n2 + 4n +2 ≠ (n3)
 3n3+ 5n2 +2n ≠ (n4)

ymp - 25
Find the Thetafor the following functions

 f(n) = 27n2 + 16n


 f(n) = 4n3 + 2n + 3
 f(n) = 2n + 6n2 +3n

ymp - 26
Incorrect bounds
 7n+5 ≠  (1)
 10n2+ 7 ≠  (n3)
 5n+8 ≠  (n2)

ymp - 27
Video Lecture of the topic can be found at

Mathematical Model of Computation


https://youtu.be/JEnXJPlXhng

Basics of Asymptotic Notations


https://youtu.be/OQZySiRblPo

ymp - 28

You might also like