Lecture Notes 2
Lecture Notes 2
Lecture 2: August 5
Instructor: Prof. Prateek Vishnoi Indian Institute of Technology, Mandi
W hat is the neat & and precise way to def ine the time complexity ? ?
Asymptotic notations
Big-oho(O) notation
Definition 2.1 Let f (n) and g(n) be positive function in n. f (n) is said to be order of g(n) if there exist a
positive constant c and n0 ∈ N such that for all n ≥ n0 ,
f (n) ≤ c.g(n)
f (n) = O(g(n))
Examples
2-1
2-2 Lecture 2: August 5
Some Observations
Judgement question
Definition 2.2 Let f (n) and g(n) be a positive function in n. f (n) is said to be omega of g(n) if there exist
a positive constant c and n0 ∈ N such that for all n ≥ n0 ,
f (n) ≥ c.g(n)
Examples
20n2 = Ω(n2 ) c = 1, n0 = 1
100n + 60 = Ω(n) c = 1, n0 = 1
100n2 + 60 = Ω(n) c = 1, n0 = 1
2
n
4 = Ω(n2 ) c = 1/8, n0 = 1
1000 = Ω(1)
Lecture 2: August 5 2-3
Some Observations
f (n) = Ω(h(n))
Judgement question
f (n) = Ω(g(n))
Definition 2.3 Let f (n) and g(n) be positive function in n. f (n) is said to be theta of g(n) if there exist a
positive constant c1 , c2 and n0 ∈ N such that for all n ≥ n0 ,
f (n) = Θ(g(n))
Keypoint : f (n) = Θ(g(n)) if and ony if f (n) = Ω(g(n)) and f (n) = O(g(n))
2-4 Lecture 2: August 5
Small o Notation
Small o notation, denoted as o(g(n)), provides a stricter form of comparison between functions.
Definition 2.4 Let f (n) and g(n) be positive function in n. A function f (n) is said to be o(g(n)) if for
every positive constant c, there exists a positive integer n0 such that:
Intuitive Understanding
Stricter Bound: While Big O notation O(g(n)) means that f (n) is eventually bounded above by a
constant multiple of g(n), small o notation means that f (n) grows strictly slower than g(n).
Upper Bound, Not Tight: If f (n) = o(g(n)), then f (n) grows at a rate that is asymptotically less
than g(n).
Example
f (n) = o(g(n)) because for any positive constant c, there exists a sufficiently large n0 such that n < cn2
for all n > n0 .
Formal Usage
f (n)
lim =0
n→∞ g(n)
This means that the ratio of f (n) to g(n) approaches 0 as n goes to infinity, indicating that f (n) grows more
slowly than g(n).
Definition 2.5 Let f (n) and g(n) be positive function in n. A function f (n) is said to be ω(g(n)) if for
every positive constant c, there exists a positive integer n0 such that:
Intuitive Understanding
Stricter Bound: While Big Omega notation Ω(g(n)) means that f (n) is eventually bounded below
by a constant multiple of g(n), small omega notation means that f (n) grows strictly faster than g(n).
Lower Bound, Not Tight: If f (n) = ω(g(n)), then f (n) grows at a rate that is asymptotically
greater than g(n).
Example
Formal Usage
Is it possible to compare every two positive functions f (n) and g(n) asymptotically??
√ n n
n! ≈ 2πn
e
Practice Problems
n! = o(nn )
n! = ω(2n )
log(n!) = Θ(n log n)