Homework 1

[Note: this webpage last modified Friday, 04-Feb-2011 19:44:51 EST]

This homework assignment will be handed out on the first day of classes, August 25 and is due by the beginning of class on the following Wednesday, so by 3pm Wednesday September 1.

  1. Using and understanding asympotic notation.

    1. (10 Points) Prove that for any two functions f and g that are polynomially bounded asymptotically (i.e., there are constants c and d such that f=O(nc) and g=O(nd)), then both h1 and h2 are polynomially bounded where we define h1 and h2 by h1(x) = f(x)*g(x) and h2(x) = f(g(x)). We refer to h1 as "the product of f and g", and we refer to h2 as "the composition of f and g".

    2. (10 Points) Prove that for any two functions f and g that are exponentially bounded asymptotically (i.e., there are constants c and d such that f=O(2nc) and g=O(2nd)) then their product is exponentially bounded. Is their composition exponentially bounded?

  2. Giving asymptotic running times of algorithms.

    1. (5 Points) Give pseudocode for a brute-force algorithm that takes as input a binary string x that is interpreted as a non-negative integer and outputs a non-trivial factor of x, "1" if x=1, or "prime" if x is prime.

    2. (10 Points) Analyze the running time of your algorithm as a function of the input length.

      You do not need to give an exact estimate, you should give a big-O estimate. Also, you can assume that integer multiplication and division of n-bit strings can be performed in time O(n2).

  3. Proof by induction.

    1. (10 Points) Let A be any finite set, and let 2A denote the power set of A - the set of all subsets of A. Prove that the cardinality of the power set is 2|A|, where |A| denotes the cardinality of A. More concisely, prove that |2A| = 2|A|.

      Hint: use induction on the cardinality of A.

    2. (5 Points) Prove how many different binary strings there are that have exactly n bits. You may use the first part of this problem if you like.

  4. (20 Points) Proof by contradiction and proof using a "reduction" (i.e., if you can solve problem A then you can solve problem B using A as a subroutine).

    Consider the halting problem, which asks to decide for a given input (M, x) whether the Turing machine M halts in finite time when given x as the input. For the purposes of this problem, you can think of a Turing machine as a Java/Python/C/etc. program if you like. The halting problem is undecidable (i.e., for any machine M' that halts in finite time on every input, there is an input (M, x) such that M' gives the wrong answer on (M, x)).

    Use the fact that the halting problem is undecidable to prove that the following problem is also undecidable. The "all strings problem" asks to decide when given the description of a Turing Machine M whether M accepts all possible inputs.

    Hint: show that a machine/program that solves the all strings problem could be used to solve the halting problem. You only need to explain how this would be done - you do not need to give Java/Python/C/etc. or Turing machine code.