Chapter 3 Answers

powered by FreeFind

Modified: 

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

Question - Which functions are in O(n2)?

n1/2, n2, n2+n2+n2, n3, n2.1? All but n3 and n2.1

Question - Show that 2n2+n is in O(n2).

0 ≤ h(n) ≤ cg(n)

0 ≤ 2n2+n ≤ cn2       

0/n2 ≤ 2n2/n2+n/n2 ≤ cn2/n2    Divide by n2  

0 ≤ 2+1/n ≤ c                               1/n = 0

0 ≤ 2+1 ≤ 3                                  with c=3 and n0=1

0 ≤ 3 ≤ 3

Question - Verify that for any a>0, any linear function an+b = O(n2)

0 ≤ h(n) ≤ cg(n)

0 ≤ an+b ≤ cn2       

0/n2 ≤ an/n2+b/n2 ≤ cn2

0 ≤ a/n+b/n2 ≤ c  Þ 0 ≤ a+|b| ≤ c for n0=1 and c=a+|b|     

                                       a/n = 0

                                       b/n2 = 0

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. 

Example - Recall we found a closed-end equation for the InsertionSort of T(n) = an2 + bn + c.

Question: a, b and c are > 0. How do we know that?

Show: T(n) = an2 + bn + c = Q(n2)

c1g(n) ≤ h(n) ≤ c2g(n)

c1n2an2 + bn + c ≤ c2n2

c1n2/n2 ≤ an2/n2 + bn/n2 + c/n2 ≤ c2n2/n2

c1 ≤ a+b/n+c/n2 ≤ c2       

as n ® ¥, b/n, c/n2 ® 0

a+b/n+c/n2 greatest when n0 = 1

c1 ≤ a+b+c when c1 = a

a+b+c ≤ c2 when c2 = a+b+c

Question (Levitin page 56)

Show that ½(n2 - n) Î Q(n2)

  • Determine $ c1, c2, n0 positive constants such that:
     
    •  c1n2 ≤ ½n2 - n/2 ≤ c2n2 
       
  • Divide through by n2 to get
    • c1 ≤ ½ - 1/2n ≤ c2 
       
  • W: Determine n0 using: c1 ≤ ½ - 1/2n
    • if n ≤ 1, then c1 ≤ 0
    • Must have c1 > 0
    • therefore, n ³ 2, so  n0 = 2
       
  • O: Determine c2 using: ½ - 1/2n ≤ c2
    • as n ® ¥, 1/2n ® 0
    • so ½ - 1/2n ® ½,
    • therefore c2 ³ ½ or c2 = ½ 
       
  • Determine c1 by plugging in n0 = 2 into ½ - 1/2n and get ½ - ¼ = ¼

     ¼*22 ≤ ½*22 - ½*2 ≤ ½*22

 ½(n2 - n) Î Q(n2) when c1 = ¼, c2 = ½ and  n0 = 2

 

Question - Does n2=Q(n2) imply n2=O(n2) and n2=W(n2)

Yes. See Theorem 3.1, page 46.

 

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:

  1. What is implied by f(n) / g(n) = ¥? f(n) grows much faster.
     
  2. 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.
     
  3. What values do O and o have in common? 0
     
  4. 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.
     
  5. What values do W and w have in common? ¥
     
  6. What other values are shared by bounds?

    W  f(n) / g(n) = c for some 0 < c ¥
    f(n) / g(n) = c for some 0 < c < ¥
                    and

    O  f(n) / g(n) = c for some 0 c < ¥
    f(n) / g(n) = c for some 0 < c < ¥
     

  7. 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)).
     
  8. 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)).
     
  9. 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

Question

n2/2n2-2n/ n2 ®  1/2-2/n ®  ½

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 < ¥

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).

  1. f(n) =  x2, g(n) = x3

    f(n) / g(n) =    x2 / x3  =  1/x  = 0 

    x2 Π O(x3) and x2 Π o(x3)

  2. f(n) =  x3, g(n) = x2

    f(n) / g(n) =    x3 / x2  =  x  = ¥

    x3 Π W(x2) and x3 Π w(x2)

  3. 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 < ¥

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