CSPP 50102 Mathematics for Computer Science—Summer 2011

Homework 5 (assigned July 21, due July 26)

Reading: Rosen chapter 3, sections 3.1–3.3.

Written assignment : Solve the following "Do" exercises and assigned problems. Only solutions to the assigned problems should be turned in. Note: You are responsible for the material covered in both "Do" exercises and assigned problems.

"Do" Exercises (not to be handed in):

  1. The following are two useful rules for computing asymptotic bounds on algebraic combinations of functions. Assume that all functions are nonnegative and real-valued.
    1. If f1(n) = Θ(g1(n)) and f2(n) = Θ(g2(n)), then f1(n) + f2(n) = Θ(max{g1(n), g2(n)}).
    2. If f1(n) = Θ(g1(n)) and f2(n) = Θ(g2(n)), then f1(n) ⋅ f2(n) = Θ(g1(n) ⋅ g2(n)).
    Use the above rules to derive Θ-estimates for the following expressions.

  2. True or false? Prove your answer.

  3. For each of the following questions, answer yes or no and briefly explain your answer.

  4. Given finite sets A and B, consider a function f : AB.

Assigned problems (to be handed in):

  1. Suppose you have algorithms with the five running times listed below. Assume these are the exact number of operations performed as a function of the input size n. You have a computer that can perform 1010 operations per second, and you need to compute a result in at most 1 hour of computation. For each of the algorithms, what is the largest input size n for which you would be able to get the result within 1 hour? (2 points each)
    1. n3
    2. 100n2
    3. n log2n
    4. 2n
    5. 22n

  2. True or false? Prove your answer using the definition of Big Oh. (5 points each)
    1. 22n = O(2n).
    2. log2 3n = O(log2 2n).

  3. For each of the following pairs of functions f (n) and g(n), give an appropriate positive constant c such that |f (n)| ≤  c ⋅ |g(n)| for all n ≥ 1. (3 points each)
    1. f (n) = 3n2 + 2n log2n + 1,   g(n) = 2n2.
    2. f (n) = n ⋅ √n  + n2,   g(n) = n2.
    3. f (n) = n2n + 1,   g(n) = n2/2.

  4. For each of the following pairs of functions, either f (n) = O(g(n)), f (n) = Ω(g(n)), or f (n) = Θ(g(n)). Determine which relationship is correct and prove your answer. Note: log = log2 throughout. (5 points each)
    1. f (n) = log n2;   g(n) = log n + 5.
    2. f (n) = log2n, where log2n = (log n) × (log n);   g(n) = log n.
    3. f (n) = n log n + n;   g(n) = log n.
    4. f (n) = 10;   g(n) = log 10.
    5. f (n) = 4n log n + n;   g(n) = (n2n)/2.

  5. Find positive and nondecreasing functions f (n) and g(n) defined for all positive integers such that neither f (n) = O(g(n)) nor g(n) = O(f (n)) holds. (10 points)

  6. Find the flaw in the following proof that any algorithm has a run time that is O(n). (10 points)
    To prove: We must show that the time required for an input of size n is at most a constant times n.
    Proof. By induction on n.
    Base case. Suppose that n = 1. If the algorithm takes c units of time for an input of size 1, the algorithm takes at most c ⋅ 1 units of time. Thus the assertion is true for n = 1.
    Inductive step. Assume that the time required for an input of size n is at most cn and that the time for processing an additional item is c′′. Then the total time required for an input of size n + 1 is at most
    cn + c′′ ≤ cn + c = c(n + 1).
    The inductive step has been verified.
    By induction, for input of size n, the time required is at most a constant time n. Therefore, the run time is O(n).


Gerry Brady
Thursday July 21 13:10:19 CDT 2011