Algorithm Design and Analysis Homework #3
Due: 1pm, Monday, November 14, 2011
=== Homework submission instructions ===
• Submit the answers for writing problems (including your programming report) through the CEIBA system (electronic copy) or to the TA in R432 (hard copy).
Please write down your name and school ID in the header of your documents.).
• Each student may only choose to submit the homework in one way; either all as hard copies or all through CEIBA except the programming assignment. If you submit your homework partially in one way and partially in the other way, you might only get the score of the part submitted as hard copies or the part submitted through CEIBA (the part that the TA chooses).
• If you choose to submit the answers of the writing problems through CEIBA, please combine the answers of all writing problems into only one file in the doc/docx or pdf format, with the file name in the format of “hw3 [student ID].{pdf,docx,doc}”
(e.g. “hw3 b99902010.pdf”); otherwise, you might only get the score of one of the files (the one that the TA chooses).
• For each problem, please list your references (they can be the names of the classmates you discussed the problem with, the URL of the information you found on the Internet, or the names of the books you read). The TA can deduct up to 100% of the score assigned to the problems where you don’t list your references.
Problem 1. (10%)
We have introduced the concept of paper prototyping in the class; to obtain the tester’s opinion, you can create a prototype (of the user interface) using a pen and a piece of paper and discuss with your testers about how your program should work. In this problem, you are asked to implement a paper prototype. Choose a software program or a device that you have used or seen, and come up with an idea to improve its usability. Create a
1
paper prototype for this improved version of program. Find 3 testers to “test out” your prototype, and gather their opinions/suggestions. At least one of the testers has to be a non-Computer-Science-major person (please specify who they are).
For this problem, you have to submit the following:
• Your paper prototype. It has to be sufficiently detailed (use arrows and short descriptions).
• 3 tester’s opinions/suggestions. Please mark the persons who are not Computer- Science-major persons.
Problem 2. (10%) Solve Problem 15.5-1 on p.403 of the textbook.
Problem 3. (15%) Describe a greedy algorithm that, given a set{x1, x2, ..., xn} of points on the real line, determines the smallest set of unit-length closed intervals that contains all of the given points. Prove that your greedy choice is correct and that the problem has optimal substructure. (Problem 16.2-5 on p.428 of the textbook)
Problem 4. (10%) The square of a directed graph G = (V, E) is the directed graph G2 = (V, E2) such that ⟨u, v⟩ ∈ E2 iff G contains a path of length equal or less than two between u and v. Both G and G2 do not have self-edges. Describe an efficient algorithm for computing G2 from G when using the adjacency list representation of G. Analyze the running time of your algorithm.
Problem 5. (15%) Consider the multistage graph G = (V, E) as shown in Figure 1. Each edge in G is assigned with a nonnegative weight.
1. (12%) Find a shortest and a longest path between S and T using dynamic program- ming.
2. (3%) Does your algorithm work if the weights are allowed to be negative? Why?
Problem 6. The outcome of the software company game will contribute to 40% of your homework 3 score and 40% of either homework 4, 5, or 6.
2
Figure 1: A multigraph
3