You are on page 1of 13

A

Asymptotic
t ti Notations
N t ti

Sahni : Page: 40, 41, 48 & 49


Cormen: Page: 45

Paris
T
Types off Time
Ti Functions
F ti
Input size n
Time Name 1 2 4 8 16 32
1 constant 1 1 1 1 1 1
log n logarithmic 0 1 2 3 4 5
n linear 1 2 4 8 16 32
n log n log linear 0 2 8 24 64 160
n2 quadratic 1 4 16 64 256 1024
n3 cubic 1 8 64 512 4096 32768
2n exponential 2 4 16 256 65536 4294967296
n! factorial 1 2 24 40326 2092278988000 26313  1033

1 < log n <√n < n < n log n < n2 < n3 < . . . < 2n < 3n < . . . < nn

Paris
Pl t off Function
Plot F ti Values
V l

60 2n
n2

50

40

n log n
30

f
20

n
10

Log n
0
0 1 2 3 4 5 6 7 8 9 10
n

Paris
A t ti N
Asymptotic t ti
Notations: “O”
O [Big “oh”] : The function f(n) = O(g(n))
iff there exist positive constants c and n0
f(n))  c  g(
such that f( g(n)) for all n,, n  n0.

 Example: 3n + 2 = O(n)
as 3n + 2  4n for all n  2

 Represents : Upper bound

Paris
“O” [U
[Upper b d] P
bound]: ti
Practice
The function f(n) = O(g(n)) iff there exist positive constants c and n0
such that f(n)  c  g(n) for all n, n  n0.

1 < log n <√n < n < n log n < n2 < n3 < . . . < 2n < 3n < . . . < nn

f(n) = 10n2 + 4n + 2

Paris
A t ti N
Asymptotic t ti
Notations: “”
 [Omega]: The function f(n) = (g(n))
iff there exist positive constants c and n0
f(n))  c  g(
such that f( g(n)) for all n,, n  n0.

 Example: 3n + 2 = (n)
as 3n + 2  3n for all n  1

 Represents : Lower bound

Paris
“” [L
[Lower b d] P
bound]: ti
Practice
The function f(n) = (g(n)) iff there exist positive constants c and n0
such that f(n)  c  g(n) for all n, n  n0.

1 < log n <√n < n < n log n < n2 < n3 < . . . < 2n < 3n < . . . < nn

f(n) = 10n2 + 4n + 2

Paris
A t ti N
Asymptotic t ti
Notations: “”
 [Theta]: The function f(n) = (g(n))
iff there exist positive constants c1, c2 and n0
g(n))  f(
such that c1 g( f(n))  c2 g(
g(n)) for all n,, n  n0.

 Example: 3n + 2 = (n)
as 3n + 2  4n and 3n + 2  3n
for all n  2

 Represents : Tight/Average bound

Paris
“”[A
“”[Average b d] P
bound]: ti
Practice
The function f(n) = (g(n)) iff there exist positive constants c1, c2 and
n0 such that c1 g(n)  f(n)  c2 g(n) for all n, n  n0.

1 < log n <√n < n < n log n < n2 < n3 < . . . < 2n < 3n < . . . < nn

f(n) = 10n2 + 4n + 2

Paris
H
Home Work
W k

f(n) = n!

Paris
N t ti
Notations: At a glance
l
O [Upper] : The function f(n) = O(g(n)) iff there exist positive constants
c and n0 such that f(n)  c  g(n) for all n, n  n0.
 [Lower]: The function f(n) = (g(n)) iff there exist positive constants
c and n0 such that f(n)  c  g(n) for all n, n  n0.
 [Tight / Average]: The function f(n) = (g(n)) iff there exist positive
constants c1, c2 and n0 such that c1 g(n)  f(n)  c2 g(n) for all n, n  n0.

Paris
Th k Y
Thank You

Paris
St S
Stay Safe
f

Paris

You might also like