Homework 0

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

This homework assignment is due before class starts on Tuesday, January 18. Your solutions should be explained in complete sentences such that your classmates will understand the solution (and can verify your proofs are correct) even if they have not solved the problems themselves.

  1. HW Polices.

    1. Type your HW (in word, latex, text file, etc.) and send to me by email.

    2. Do NOT share electronically. You must type your own solutions. You can discuss the problems with each other, but you may only discuss them. You may not write out solutions together.

    3. You MAY NOT search the Internet, textbooks, etc. for solutions to the problems. The following are the ONLY sources of information that you may use in solving the problems: the textbook for this course, wikipedia articles on basic math/probability/etc., and mathematical review material at the following MIT opencourseware page: 6.042J / 18.062J Mathematics for Computer Science, Fall 2005. You may discuss the problems with each other and with myself, but must obey the previous item in doing so.

      If you do find the solution in one of these three sources, you still MUST cite the source in your document.

      You may use NOTHING ELSE that is online or other textbooks.

    4. You MAY NOT copy word-for-word from any source, even the three you are allowed to consult. If you feel it is necessary, you should put the quotation in quotes and provide a reference/citation.

  2. (-3 points if left blank) List who you collaborated with on this assignment, "none" if none.

  3. (2 Points) Prove or disprove: if x and y are irrational numbers, then x*y is irrational.

  4. (2 Points) Prove or disprove: if x and y are rational numbers, then x*y is rational.

  5. Consider the following algorithm written in pseudocode that is supposed to determine whether two vertices in an undirected graph are connected.
    	 Function: connected
    	 Input: graph G and vertices s, t.  
    	 if s==t then return true
    	 if G is empty (empty vertex set or empty edge set) then return false
    	 for each neighbor v of s
    	   let G' be G but with s removed.
    	   if connected(G', v, t) return true
    	 return false	 
           

    (3 Points) Prove using induction that the algorithm is correct - that it always returns the correct answer. You should use induction on the size of the graph. First prove that the algorithm is correct for graphs with 1 or 2 vertices. Then show that if it is correct on graphs with n vertices it must be correct for graphs with n+1 vertices.

    (3 Points) Analyze the running time of the algorithm by counting the number of times the line "if s==t then return true" is executed. First, consider a graph that consists of two disjoint rings of 5 vertices each, let s be a vertex from one of the rings and t a vertex from the other (so s is not connected to t). How many times is the line executed for this graph? Second, give a big-O upper bound on the number of times the line is executed on any graph that has n vertices - as a function of n.

    What would the running time of the algorithm be if we had set G'=G rather than setting G' equal to G without s?