Chapter 3 Answers |
Asymptotic Notations
Question - 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 - 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 |
|
W Omega Notation
Example - v n = W(lg n) with c=1 and n0=16
Question - How do we know that this is true for n ³ n0=4? Rate of growth of lg n < v n
Example - n3 = W(n2) with c=1 and n0=1
Question - 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 - Which functions are in W(n2)? n2, n2+n2+n2, n!, n3, n2.1
Question - Show that 2n2+n is in W(n2)
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 1/n = 0
What is c and n0? c=2 and n0=1.
Q Theta Notation
Question: 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 What is implied by
f(n) / g(n) = 0? g(n) is much larger than f(n).
Question - Using limits show:
n2/lg n = o(n2)
(n2/lg n)/n2 =
1/lg n = 0
n2 ¹ o(n2)
n2/n2 = 1
Question - 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-w Notation
Question
Show n2/lg n ¹ w(n2)
(n2/lg n)/n2 =
1/lg n = 0
What is the
n1.9999/n2?
n1.9999/n2=0
Is n1.999 = w(n2)?
No.
Limits
Question - Examining the limit definitions:
- What is implied by
f(n) / g(n) = ¥? f(n) grows much faster.
- 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 W? f(n) grows much faster. Also that f(n) is non-asymptotically tight.
- What values do W and w have in common? ¥
- What other values are shared by bounds?
W
f(n) / g(n) = c for some 0 < c ≤ ¥
Qf(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)=W(g(n)) and f(n)=O(g(n)) imply f(n)=Q(g(n))? Yes, though 0 and ¥ not included if f(n)=W(g(n)) and f(n)=O(g(n)).
- Does f(n)=Q(g(n)) imply f(n)=W(g(n)) and f(n)=O(g(n))? Yes, though 0 and ¥ not included if f(n)=Q(g(n)).
- Why does it make sense to say that is Q asymptotically tight? f(n) is only less than or greater than g(n) by some constant.
Question
- 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= w(n2)?
f(n) / g(n) = ¥ Yes.
- Which of f(n) or g(n) is more efficient? g(n)
Question
- 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. 1/3 ≤ 1/4 ≤ 2 for n³8 is false.
- n2/2-2n = Q(n2), is it also O(n2) and W(n2)? Yes.
Definition of O, Q, W, o, and w by limits W
f(n) / g(n) = c for some 0 < c ≤ ¥
O
f(n) / g(n) = c for some 0 ≤ c < ¥
Q
f(n) / g(n) = c for some 0 < c < ¥
o
f(n) / g(n) = 0
w
f(n) / g(n) = ¥
Question - 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 Î W(x2) and x3 Î w(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 - What does the example mean? O, Q, W, w, o? n2 = o(2n) and n2 = O(2n)
Definition of O, Q, W, o, and w by limits W
f(n) / g(n) = c for some 0 < c ≤ ¥
O
f(n) / g(n) = c for some 0 ≤ c < ¥
Q
f(n) / g(n) = c for some 0 < c < ¥
o
f(n) / g(n) = 0
w
f(n) / g(n) = ¥
Factorials
2. n! = w(2n) by inspection. Question - Explain. n!=1*2*3*...*n-1*n > 2*2*2*...*2*2 for n>3