Homework 4

[Note: this webpage last modified Wednesday, 02-Mar-2011 09:15:57 EST]

This homework assignment is due before class starts on Tuesday, March 1. 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. (-2 points if left blank) List who you collaborated with on this assignment, "none" if none.

  3. (6 Points) Let Quasi-P be the set of languages that can be solved by a deterministic Turing machine in time 2(log n)O(1). For example, time nlog n or n(log n)3. Let Quasi-NP be the set of languages that can be solved by a nondeterministic algorithm that runs in time 2(log n)O(1), that is they have verifiers that take a certificate of that size and run in that amount of time.

    Show that if P=NP then Quasi-P = Quasi-NP.

    Hint: Quasi-P is contained in Quasi-NP "obviously" (but if it is not obvious to you, you should convince yourself why). To show that Quasi-NP is contained in Quasi-P, start with a language L in Quasi-NP and show that it can be solved in Quasi-P. You will need to use the assumption that P=NP somehow; the trick is to use a "padding trick" like the one used to prove the nondeterministic time hierarchy theorem.

  4. (4 Points) Pick your favorite programming language, and write a program to solve both the 2-coloring and 3-coloring problems on undirected graphs. You should represent the graph as an adjacency matrix.

    2-coloring can be solved in polynomial time with the following algorithm. Choose one of the vertices to color red. All of its neighbors must be black. Each of the neighbors of those must be red. Etc. If at any time you run into a conflict (trying to color a node red that is already black, or vice versa), then the graph is not 2-colorable.

    For both your 2-coloring and 3-coloring algorithms, the program should output either "not 2/3-colorable" or output a 2/3-coloring.

    You should send your program as a separate file attached to your email. You should also answer the following question. What is the largest graph size that your 2-coloring algorithm can solve in less than 10 seconds? What about your 3-coloring algorithm?

    Extra credit. I will count the following as extra credit if you do it. Write programs to solve both the shortest-path and longest-path problems. The shortest path problem takes as input a graph and 2 vertices s and t, and produces the shortest path between s and t. The longest path problem asks for the longest simple path (no cycles on the path) between s and t. You should solve the shortest path problem using an efficient algorithm (e.g., DFS or BFS). The longest path problem is NP-hard, so you should use the "try all possibilities" algorithm for this one. This is due Tuesday, March 15. Even if you did turn in correct answers for 2/3 coloring, you can do this for extra credit if you want to.