0% found this document useful (0 votes)
187 views15 pages

Lect 7 - Asymptotic Notation-2

The document defines and provides examples for big O notation (O), omega notation (Ω), and theta notation (Θ) which describe asymptotic upper bounds, lower bounds, and tight bounds of functions. It shows that O notation provides an upper bound, Ω notation provides a lower bound, and Θ notation provides tight bounds that simultaneously give both an upper bound and a lower bound for a function. Examples are given to demonstrate determining the constants and thresholds needed to prove asymptotic bounds between functions.

Uploaded by

kaushik.gr
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)
187 views15 pages

Lect 7 - Asymptotic Notation-2

The document defines and provides examples for big O notation (O), omega notation (Ω), and theta notation (Θ) which describe asymptotic upper bounds, lower bounds, and tight bounds of functions. It shows that O notation provides an upper bound, Ω notation provides a lower bound, and Θ notation provides tight bounds that simultaneously give both an upper bound and a lower bound for a function. Examples are given to demonstrate determining the constants and thresholds needed to prove asymptotic bounds between functions.

Uploaded by

kaushik.gr
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/ 15

•1

Asymptotic Notations-
2
O-notation
•2

 Given functions f(n) and g(n), we say that


f(n) is O(g(n)
 If there exist positive constant c and n0 such that
f(n) ≤ c g(n) for all n ≥ n0
 g(n) is an asymptotic upper bound for f(n).
 Example
 5n2+2n+1 O(n2)

 5n2+2n+1 ≤ 8 n2
 c=8 and n ≥ 1
 -notation
•3

 Given functions f(n) and g(n), we say that


f(n) is  (g(n)
 If there exist positive constant c and n0 such that
f(n) ≥ c g(n) for all n ≥ n0
 g(n) is an asymptotic lower bound for f(n).
 Examples:
 5n2+2n+1   (n2)

 5n2+2n+1 ≥ 5 n2

 c=5 and n ≥ 0
-notation
•4

 Given functions f(n) and g(n), we say that


f(n) is (g(n)
 If there exist positive constant c1 and c2 and n0 such that
c1 g(n)  f(n)  c2 g(n) for all n  n0
 g(n) is an asymptotically tight bound for f(n).
 Examples:

5n2+2n+1 (n2)

5 n2  5n2+2n+1  8 n2
c =8, c =5, and n ≥ 1
1 2
Tight, loose UB and LB
•5

 n2+n+5 ≤ 7. n2 Tight U.B


≤ 10. n3
≤ 4. n4 Loose U.B
≤ 3. 2n
 n2+n+5 ≥ n2 Tight L.B

≥n
≥ log n Loose L.B
≥5 n2+n+5   (n2)
n2 ≤ n2+n+5 ≤ 10 n2 ,c1=1, c2=10, n ≥ 1
Big-O example, graphically
 Note 30n+8 isn’t
less than n
anywhere (n>0). cn =
31n 30n+8

Value of function 
 It isn’t even
less than 31n
everywhere.
30n+8
 But it is less than n
31n everywhere to O(n)
the right of n=8.
n>n0=8 
Increasing n 

•6
More Examples
•7

 O-notation  O-notation
 n  O(n2)  n3 ∉ O(n2)
 100n+5  O(n2)  0.00001n3 ∉ O(n2)
 ½ n (n-1)  O(n2)
 n4 + n + 1 ∉ O(n2).
  -notation
 n3 ∈ (n2)
  -notation
 0.1n3  (n2)  100n + 5 ∉ (n2).
 ½ n (n-1)  (n2)  n2 ∉  (n4 + n + 1)
 -notation  n2 ∉ O(n3)
 0.3n2 - 2n  (n2)
 ½ n(n-1)  (n2)
O-notation example- Find c and n0
•8

 4n  O(5n),
 c=1, n ≥ 0
 4n  O(n),
 c=4, n ≥ 0
 4n+3  O(n),
 c=5, n ≥ 3
 n  O(0.001n2) ,
 c=1, n ≥ 100
-notation examples-Find c and n0
•9

 5n   (4n),
 c=1, n ≥ 0
 n   (4n),
 c=1/4, n ≥ 0
 4n+3   (n),
 c=1, n ≥ 1
-notation example-Find c and n0
•10

 4n  (n),
 c1=1, c2=4, n ≥ 1
 4n+3  (n),
 c1=1, c2=5, n ≥ 3
No Uniqueness
 There is no unique set of values for n0 and c in proving the
asymptotic bounds
 Prove that 100n + 5 = O(n2)
 100n + 5 ≤ 100n + n = 101n ≤ 101n2

for all n ≥ 5

n0 = 5 and c = 101 is a solution


 100n + 5 ≤ 100n + 5n = 105n ≤ 105n 2
for all n ≥ 1

n0 = 1 and c = 105 is also a solution


•11
Must find SOME constants c and n0 that satisfy the asymptotic notation relation
Common orders of magnitude

•12
Basic asymptotic efficiency classes
1 constant

log n logarithmic

n linear

n log n n-log-n

n2 quadratic

n3 cubic

2n exponential

n! factorial
Relation between O, 

(g)=O(g) ⋂ (g)

You might also like