Lecture 06ppt PDF
Lecture 06ppt PDF
Algorithms – p. 100
Asymptotic Notation
Formally
Θ(g(n)) = {f(n) | there exist positive
constants c1 , c2 and n0 such that
0 ≤ c1 g(n) ≤ f(n) ≤ c2 g(n)
for all n ≥ n0 }
Algorithms – p. 101
Asymptotic Notation
Formally
Θ(g(n)) = {f(n) | there exist positive
constants c1 , c2 and n0 such that
0 ≤ c1 g(n) ≤ f(n) ≤ c2 g(n)
for all n ≥ n0 }
Your response at this point might be, “I am sorry that I
asked!”
Algorithms – p. 101
Asymptotic Notation
• This is written as “f(n) ∈ Θ(g(n))”
• That is, f(n) and g(n) are asymptotically
equivalent.
• This means that they have essentially the
same growth rates for large n.
Algorithms – p. 102
Asymptotic Notation
• 4n2 ,
• (8n2 + 2n − 3),
2
√
• (n /5 + n − 10 log n)
• n(n − 3)
Algorithms – p. 104
Asymptotic Notation - Example
f(n) = 8n2 + 2n − 3
• Lower bound: f(n) = 8n2 + 2n − 3 grows
asymptotically at least as fast as n2 ,
• Upper bound: f(n) grows no faster
asymptotically than n2 ,
Algorithms – p. 105
Asymptotic Notation - Example
Algorithms – p. 106
Asymptotic Notation - Example
• We implicitly assumed that 2n ≥ 0 and
n2 − 3 ≥ 0
√
• These are not true for all n but if n ≥ 3, then
both are true.
√
• So select n0 ≥ 3.
• We then have f(n) ≥ c1 n2 for all n ≥ n0 .
Algorithms – p. 107
Asymptotic Notation - Example
Algorithms – p. 108
Asymptotic Notation - Example
• We implicitly made the assumption that
2n ≤ 2n2 .
• This is not true for all n but it is true for all
n≥1
• So select n0 ≥ 1.
• We thus have f(n) ≤ c2 n2 for all n ≥ n0 .
Algorithms – p. 109
Asymptotic Notation - Example
√
• From lower bound we have n0 ≥ 3
• From upper bound we have n0 ≥ 1.
• Combining the√two, we let n0 be the larger of
the two: n0 ≥ 3.
Algorithms – p. 110
Asymptotic Notation - Example
• In conclusion,
√ if we let c1 = 7, c2 = 10 and
n0 ≥ 3, we have
√
7n2 ≤ 8n2 + 2n − 3 ≤ 10n2 for all n ≥ 3
• We have thus established
0 ≤ c1 g(n) ≤ f(n) ≤ c2 g(n) for all n ≥ n0
Algorithms – p. 111
Asymptotic Notation - Example
Asymptotic Notation
1e+11
8n^2+2n-3
7n^2
10n^2
8e+10
6e+10
f(n)
4e+10
2e+10
0
0 20000 40000 60000 80000 100000
n
Algorithms – p. 112
Asymptotic Notation - Example
• We have established that f(n) ∈ n2 .
• Let’s show why f(n) is not in some other
asymptotic class.
• First, let’s show that f(n) 6∈ Θ(n).
Algorithms – p. 113
Asymptotic Notation - Example
Algorithms – p. 114