Chapter 3 Answers |
Document last modified: |
Asymptotic Notations
Question 3.1 - What is:
(1/x + 3) 3 because 1/x limit is 0
2x/10x 1/5 because x/x limit is 1
2x/10x2 0 because growth rate of x2 greater than x
lg x/x2 0 because growth rate of x2 greater than lg x
Question 3.2 - Why is n=O(n2) but n3≠ O(n2)?
Because for
f(n) / g(n) = c;
n/n2 = 0 = c
n3/n2 = ∞
| O Big-O Notation |
|
Ω Omega Notation
Example - n3 = Ω(n2) with c=1 and n0=1
Question 3.6.1 - Show using limits:
Ω
f(n) / g(n) = c for some 0 < c ≤ ∞
- 1/n ≠ Ω(n2)
1/n/n2 =
1/n3 = 0
- n2/1000 = Ω(n2)
n2/1000/n2 =
1/1000 = 1/1000
Question 3.6.2 - Can we use n0=0 above? No, would require c=0 but must have c>0. Also n0 refers to problem size, a positive integer.
Question 3.6.3 - From the two graphs, is c=3 and n0=1 the better choice? Why? Tighter bounds, 3g(n) more accurately characterizes f(n).
3n2 + n = Ω(n2) with c=1 and n0=1
3n2 + n = Ω(n2) with c=3 and n0=1
Example - v n = Ω(lg n) with c=1 and n0=16
Question 3.7 - How do we know that this is true for n ≥ n0=4? Rate of growth of lg n < v n
Question 3.8 - Which functions are in Ω(n2)? n2, n2+n2+n2, n!, n3, n2.1
Question 3.9 - Show that 2n2+n is in Ω(n2)
Find c 0 ≤ cg(n) ≤ h(n) 0 ≤ cn2 ≤ 2n2+n 0/n2 ≤ cn2/n2 ≤ 2n2/n2+n/n2 0≤ c ≤ 2+1/n 0 ≤ c ≤ 2 c must always be ≤ 2+1/n
1/n = 0
so 2 ≤ 2+1/nFind n0 0≤ 2 ≤ 2+1/n0 -2 ≤ 0 ≤ 1/n0 Satisfied by n0 ≥ 1 What is c and n0? c=2 and n0=1.
Θ Theta Notation
Question 3.10 Does the following hold for ∀n ≥ n0?
c1n2 ≤ n2/2-2n ≤ c2n2 with c1=1/4, c2=1/4 and n0=8
No.
2/n = 0 so 1/4 ≤ 1/2 ≤ 1/4 is false.
|
Little-O Notation
Question 3.14 What is implied by
f(n) / g(n) = 0? g(n) is much larger than f(n).
Question 3.15 - Using limits show:
n2/lg n = O(n2)
(n2/lg n)/n2 =
1/lg n = 0
n2 ≠ O(n2)
n2/n2 = 1
Question 3.16 - Classify n2.001 and n1.999 as O(n2) or not from the graph at right.
n2.001 ≠ O(n2) since limit increasing to ∞ and n1.999 = O(n2) since decreasing to 0.
Little-Ω Notation
Question 3.17
1. What is implied by
f(n) / g(n) = ∞?
f(n) grows faster.
2. Show n2/lg n ≠ Ω(n2)
(n2/lg n)/n2 =
1/lg n = 0
3. What is the
n1.9999/n2?
n1.9999/n2=0
4. Is n1.999 = ω(n2)?
No.
Limits
Question 3.18 - Examining the limit definitions:
- What is implied by
f(n) / g(n) = c = 0 in the definition of O? g(n) grows much faster. Also that f(n) is non-asymptotically tight.
- What values do O and O have in common? 0
- What is implied by
f(n) / g(n) = c = ∞ in the definition of ω? f(n) grows much faster. Also that f(n) is non-asymptotically tight.
- What values do ω and Ω have in common? ∞
- What other values are shared by bounds?
Ω
f(n) / g(n) = c for some 0 < c ≤ ¥
Θf(n) / g(n) = c for some 0 < c < ∞
andO
f(n) / g(n) = c for some 0 ≤ c < ∞
Qf(n) / g(n) = c for some 0 < c < ∞
- Does f(n)=ω(g(n)) and f(n)=O(g(n)) imply f(n)=Θ(g(n))? Yes, though 0 and ∞ not included if f(n)=ω(g(n)) and f(n)=O(g(n)).
- Does f(n)=Θ(g(n)) imply f(n)=ω(g(n)) and f(n)=O(g(n))? Yes, though 0 and ∞ not included if f(n)=Θ(g(n)).
- Why does it make sense to say that is Θ asymptotically tight? f(n) is only less than or greater than g(n) by some constant.
Question 3.19
- Does 0 ≤ f(n) < cg(n) appear correct for n1.999 = O(n2)?
f(n) / g(n) = 0 Yes.
- Which of f(n) or g(n) is more efficient? f(n)
- Does 0 ≤ cg(n) < f(n) appear correct for n2.001= Ω(n2)?
f(n) / g(n) = ∞ Yes.
- Which of f(n) or g(n) is more efficient? g(n)
Question
3.20
- In
(n2/2-2n) / n2 → constant - What is the constant?
n2/2n2-2n/ n2 →
1/2-2/n → ½
- Does the limit appear to agree with the graph? Yes.
- c1g(n) ≤ h(n) ≤ c2g(n) with c1=1/4, c2=1/2 and n0=8. What about c1=1/3, c2=2?
No. 21 1/3 ≤ 16 ≤ 128 is false for n=8
1/3 n2 ≤ n2/2-2n ≤ 2n2
- n2/2-2n = Θ(n2), is it also O(n2) and Ω(n2)? Yes.
Definition of O, Θ, Ω, O, and Ω by limits Ω
f(n) / g(n) = c for some 0 < c ≤ ∞
O
f(n) / g(n) = c for some 0 ≤ c < ∞
Θ
f(n) / g(n) = c for some 0 < c < ∞
O
f(n) / g(n) = 0
Ω
f(n) / g(n) = ∞
Question 3.21 - Compare f(n) and g(n).
f(n) = x2, g(n) = x3
f(n) / g(n) =
x2 / x3 =
1/x = 0
x2 ∈ O(x3) and x2 ∈ O(x3)
f(n) = x3, g(n) = x2
f(n) / g(n) =
x3 / x2 =
x = ∞
x3 ∈ Ω(x2) and x3 ∈ ω(x2)
f(n) = 2x2, g(n) = x2
f(n) / g(n) =
2x2 / x2 =
2 = 2
2x2 ∈ Q(x2)
Exponentials
Example - For all real constants a and b such that a > 1,
nb/an = 0
The graph at right is of n2/2n
Question 3.22 - What does the example mean? O, Θ, Ω, w, O? n2 = O(2n) and n2 = O(2n)
Definition of O, Θ, Ω, O, and Ω by limits ω
f(n) / g(n) = c for some 0 < c ≤ ∞
O
f(n) / g(n) = c for some 0 ≤ c < ∞
Θ
f(n) / g(n) = c for some 0 < c < ∞
O
f(n) / g(n) = 0
Ω
f(n) / g(n) = ∞
Factorials
2. n! = ω(2n) by inspection.
Question 3.23 - Explain. n!=1*2*3*...*n-1*n > 2*2*2*...*2*2 for n>3