Lecture 1 Asymptotic Notations
Lecture 1 Asymptotic Notations
Instructor
Neelima Gupta
[email protected]
Table Of Contents
Growth Functions
Introduction
• For each problem to be solved, we may have multiple
algorithms as solution. However, the best must be
chosen.
• Comparison of the algorithms depends mainly on:
– Time Complexity
Time the algorithm takes to run.
– Memory Space
Memory the algorithm requires.
f2(n
)f (
1
n)
no
Let c = 1
Claim: n2 1(n2-n)
Proof:
To show: n2<=n(n-1)
T.S: n n-1, which is not true for any value of n.
Let c = 2
Claim: n2 2(n2-n)
Proof:
T.S: n2 2n2-2n
T.S: 2n n2, which is true for n 2.
Hence, f(n) = O(g(n))
Sol: g(n) = n2 – n
≤ n2 for all n ≥ 1
= f(n)
g(n) ≤ f(n) for all n ≥ 1
Sol: g(n) = n3 - n2 – n
≤ n3 for all n ≥ 1
= f(n)
g(n) ≤ f(n) for all n ≥ 1
f(n)
cg(n)
Thus,
n1/2 = o( n)
we can also write it as n1/2 < n. Combining the
previous result
n1/2 < n < n2 < n3
Relation between n & log n
log n = o( n1/2 )
or
log n < n1/2
Combining the results we get
log n < n1/2 < n < n2 < n3
Relation between n 2 & nlog n
• Since log n = o(n)
for c > 0, n0 > 0 such that n n0, we
have
log n < c n
Multiplying by n on both sides we get
n log( n ) < c n2 n n0
nlog n = o( n2 )
nlog n < n2
Relation between n & nlog n
Solution: let c> 0 be any constant such that
n < c n log (n)
1 < c log( n )
log( n) > 1 / c
n > e1/c
i.e. n < c n log n n > e1/c
Since c was chosen arbitrarily
\ n =o(n log n )or n < n log n
log n < n/log n < n1/2 < n < n logn < n2 < n3
Assignment No 3
• Show that
– lim f(n)/g(n) = 0 => f(n) = o(g(n)).
n→∞
– lim f(n)/g(n) = c => f(n) = θ(g(n)).
n → ∞, where c is a positive constant.
• Show that log n = o(n).
• Show that n^k = o(2^n) for every
positive constant k.
• Show by definition of ‘small o’ that
a^n = o(b^n) whenever a < b , a and b are
positive constants.
Hence we have,
log n < n/log n < n1/2 < n < n logn < n2 < n3
<2n < 3n