# CMPSCI 611: Theory of Algorithms

### Midterm Exam

There are seven questions for 100 total points. The scale is A=90, B=60. The first four problems are "true/false with explanation".

• Question 1 (10): (true/false with explanation) Let G be a connected undirected graph with positive edge weights. Let e be a particular edge of G such that for any other edge e', the weight w(e) is strictly less than w(e'). Then if T is any minimum spanning tree of G, then e is one of the edges of T.
• Question 2 (10): (true/false with explanation) Let G be a weighted directed graph with exactly one source s and exactly one sink t. Let (A,B) be a maximum cut in G, that is, A and B are disjoint sets whose union is V, s ∈ A, t ∈ B, and the sum of the weights of all edges from A to B is the maximum for any two such sets. Now let H be the weighted directed graph obtained by adding 1 to the weight of each edge in G. Then (A,B) must still be a maximum cut in H.
• Question 3 (10): (true/false with explanation) Suppose that given two n-bit numbers X and Y, each divided into three pieces of n/3 bits each, I can determine the product XY using six multiplications of one n/3-bit piece by another, plus some fixed number of additions. Then I can use this method to devise a method to multiply any two n-bit numbers in O(n1+log32) time.
• Question 4 (10): (true/false with explanation) Let G be a complete n-vertex undirected graph with positive integer edge weights, and let A be the matrix such that Aij is the weight on the edge from i to j. (For each i, Aii = 0.) Then for each i and j, An-1ij gives the shortest-path distance from i to j, where the matrix multiplication is carried out using ordinary integer addition and multiplication.
• Question 5 (15): Let E be a finite set of intervals on the line, so that each interval ei has a start point si and a finish point fi. Let I be the set of all sets of intervals in E such that no two intervals in X overlap. That is, there do not exist ei and ej in X such that si < sj < fi. Prove that I is a subset system (which means that it is closed downward under inclusion). Prove that it need not be a matroid.
• Question 6 (25): Let E be a finite set of intervals as in Question 5, with the additional property that each interval ei has a positive weight wi. Consider the optimization problem of finding a non-overlapping set of intervals that maximizes the total weight of the intervals in the set. You may assume that all the start and finish points are distinct (and that no start point equals any finish point).
• (a,10) Give an example showing that the simplest greedy strategy (always choosing the heaviest remaining interval that does not overlap with those already chosen) can fail to find the optimal set of intervals.
• (b,15) Explain a dynamic programming algorithm that finds the optimal set in time that is polynomial in the number of intervals. (Hint: First sort the intervals by finish time, than for each i from 1 to n, compute the best set of intervals among the first i to finish.)
• Question 7 (20): Let E be a set of elements and let C be a set of attributes, such that each element may have zero, one, or more than one attribute. Recall from HW#2 that a traversal is a set T ⊆ E such that there exists a subset A of C, with |A| = |T|, and a one-to-one function f from T to A such that each element a in T has attribute f(a) (perhaps along with other attributes). That is, it is possible to pick an attribute held by each element in T such that no attribute is used twice.

Given the information as to which element has which attribute, describe how to define a flow network such that a maximum flow through the network can be used to find a traversal of maximum possible size. Explain carefully why the maximum flow has to be of the form necessary to define the traversal.