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

Question 3.3 - Which functions are in O(n2)?

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

Question 3.4 - 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 3.5 - Verify that for a>0, b>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

Ω 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. 1/n ≠ Ω(n2)

    1/n/n2 = 1/n3 = 0
     

  2. 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/n
Find 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. 

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

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

Show: T(n) = an2 + bn + c = Θ(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 3.12 (Levitin page 56)

Show that ½(n2 - n) ∈ Θ(n2)

  • Determine ∃ c1, c2, n0 positive constants such that:
     
    •  c1n2 ≤ ½n2 - n/2 ≤ c2n2 
       
  • Divide through by n2 to get
    • c1 ≤ ½ - 1/2n ≤ c2 
       
  • Ω: 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) ∈ Θ(n2) when c1 = ¼, c2 = ½ and  n0 = 2

 

Question 3.13 - Does n2=Θ(n2) imply n2=O(n2) and n2=Ω(n2)

Yes. See Theorem 3.1 of the text.

 

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:

  1. 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.
     
  2. What values do O and O have in common? 0
     
  3. 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.
     
  4. What values do ω and Ω have in common? ∞
     
  5. 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 < ∞
                    and

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

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

  1. Does 0 ≤ f(n) < cg(n) appear correct for n1.999 = O(n2)?  f(n) / g(n) = 0  Yes.
     
  2. Which of f(n) or g(n) is more efficient? f(n)
     
  3. Does 0 ≤ cg(n) < f(n) appear correct for n2.001= Ω(n2)?  f(n) / g(n) = ∞  Yes.
     
  4. Which of f(n) or g(n) is more efficient? g(n)

Question 3.20

  1. In (n2/2-2n) / n2 → constant - What is the constant? 

    n2/2n2-2n/ n2 →  1/2-2/n →  ½
     

  2. Does the limit appear to agree with the graph? Yes.
     
  3. 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 n2n2/2-2n ≤ 2n2

  4. 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 < ∞

f(n) / g(n) = 0 

Ω  f(n) / g(n) = ∞    

Question 3.21 - 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 ∈  Ω(x2) and x3 ∈  ω(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 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 < ∞

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