Solutions to Practice Final Exam for CMPSCI 611, Fall 2005
Q1: 10 points Q2: 10 points Q3: 10 points Q4: 10 points Q5: 15 points Q6: 25 points Q7: 20 points
Question text in black, answers in blue.
Correction in orange made 20 Dec 2005.
TRUE. Integer programming is NP-hard, because we can take the
NP-complete VERTEX-COVER problem and create an integer program
whose minimum value is the size of the smallest vertex cover. (Make a
variable for each vertex, restricted to be 0 or 1, make a constraint
xu + xv ≥ 1 for each edge (u,v)., and minimize
x1 + ... + xn.)
If we could reduce integer programming to an equivalent linear programming
problem in polynomial time, we could solve the latter problem in time
polynomial in its size by one of the P algorithms for LP that
we didn't present in lecture. The size of the linear program must be only
polynomial in the size of the integer program because the poly-time conversion
algorithm only has time to output a linear program of polynomial size.
TRUE. The algorithm chooses k vertices randomly and independently and says "yes" iff these vertices form a clique. This is clearly polynomial time as there are only (k choose 2) edges to check. If there is no clique of size k, the set chosen by the algorithm will certainly not be a clique, and the algorithm will always correctly say "no". If there is a clique of size k, there is a small (at least 1/(n choose k)) chance that the algorithm will choose those vertices and correctly say "yes". So the algorithm meets the given specifications, though its success probability in the worst case is so small as to make it totally useless.
TRUE. B will run A independently k times, where k will be computed below,
and answer "yes" iff at least one of the A-answers is "yes". If the correct
answer is "no", then each A run will answer "no" and B will answer "no" --
in this case B is correct with probability 1. If the correct answer is "yes",
the probability that each run of A answers "no" is at most 1 - 1/n2.
The probability that k consecutive runs of A all answer "no" is at most
(1 - 1/n2)k. This is the only situation in which B
is incorrect.
So it suffices to pick k so that (1 - 1/n2)k is
at most 1/4. Remember that (1 - 1/n2)n2 is
very close to 1/e. So setting k to be 2n2, we get a probability
about 1/e2 which is less than 1/4 because e is about 2.71828,
greater than 2.
FALSE. It is true that the metric TSP has such an approximation. But for any constant k, we can prove that if a k-approximation to general TSP exists, then P = NP. Fix k. We can reduce the NP-complete HAMILTON-CIRCUIT problem to general TSP by a function that maps an undirected graph G to a weighted complete graph H with the same vertex set -- we map edges of G to edges of weight 1 in H, and non-edges of G to edges of weight (k+1)n in H. Then a Hamilton circuit of G maps to a Hamilton circuit in H of weight n, and any Hamilton circuit of H that does not come from a Hamilton circuit of G has weight at least n - 1 + k(n+1) which is greater than kn. Thus a k-approximation to the general TSP problem on H would decide whether G has a Hamilton circuit and thus decide HAMILTON-CIRCUIT. If this can be done in polynomial time, then P = NP.
Suppose we have a linear program defined by the equation Ax = b, where A is an m by n matrix and the rows of A are linearly independent. We think of the feasible region as a polytope in (n-m)-dimensional space, where each vertex is the intersection of n-m of the constraint planes. If we are at a vertex, n-m of the n entries of x are zero. We can move to another vertex by choosing one of these n-m entries and increasing it, while adjusting the other variables to maintain Ax = b, until another entry becomes zero. There are at most n-m ways to do this and thus at most n-m neighbor vertices of the polytope.
Put every item in a separate bin. So if there are n items, the algorithm's score is n. The total size of the items is more than n/3, so the optimal algorithm must use at least n/3 bins. (In fact since no more than two of these items will fit in a bin, the optimal algorithm must use at least n/2 bins and this algorithm is a 2-approximation as well as a 3-approximation.)
An item of size ≥ 2/3 must go in its own bin, so put each of these items in its own bin and consider the n other items. Make a graph G where each vertex represents an item and there is an edge between any two items whose total size is at most 1. A matching of e edges in this graph represents a valid bin packing where the two items represented by the endpoints of each edge go in a single bin, and the other n - 2m items each go in a single bin. This packing uses n - e bins (plus those for the big items already dealt with), and any valid packing must correspond to a matching in this graph. So the MAXIMUM-MATCHING solution, a matching with the largest possible value of e, gives us a bin packing with the smallest possible value of n - e and thus the smallest possible number of bins.
Sort the items from largest to smallest. Look at the largest and smallest
items in the list. If they fit together in a bin, put them there, otherwise
put the largest item in its own bin. Continue this process until all items
are placed in bins. This takes O(n log n) time to sort plus O(n) time to
reduce the list to an empty set.
We claim that this packing is optimal. We only put an item in a bin by
itself when there is no matching item available, and when we check a largest
item L with a smallest item S, we have already matched all items smaller than
S with other items. So if we put L in a bin by itself, there is no way to
match L except with an item that has already been matched with an equal or
larger item.
We reduce VERTEX-COVER to DOMINATING-SET. Given an undirected graph G and
a number k, we build a graph H so that G has a vertex cover of size at most
k iff H
has a dominating set of size at most k.
We will do this by showing that G has a vertex cover of size exactly k iff
H has a dominating set of size exactly k, so that the range of sizes of the
two types of sets is exactly the same.
(Then the reduction function will map (G,k) to (H,k).)
H will have a vertex for each vertex of G, except
for any isolated vertices (vertices of degree 0), and a new vertex vu for
each edge e of G. Each edge e = (u,v) of G is replaced by a triangle of edges
in H: (u,v), (u,ve), and (v,ve).
We must prove that G has a vertex cover of size k iff H has a dominating set
of size k. If X is a vertex cover of G, then X is also a dominating set of H
because every edge of G has a vertex in X incident to it, and so every triangle
of vertices in H has at least one member of X in it, and so every vertex of H
is either in X or adjacent to a vertex in X. So if G has a vertex cover of
size k, then H has a dominating set of size k. Note that
this argument assumes that every vertex of H is in one of the triangles, which
is why we have to avoid replicating any isolated nodes in H.
It is a little more complicated to show that if H has a dominating set of size
k, then G has a vertex cover of size k. Let Y be a dominating set of k nodes
of H. Note that if any vertex in Y is an edge-vertex ve
rather than a vertex of
G, we can replace it by one of the G-vertices for the edge e's endpoints and
it will still be a dominating set. (This is because ve only
dominated three vertices, those in its triangle, and either of the other two
vertices in this triangle also dominate these three vertices.) Once we have
replaced all edge-vertices in Y by G-vertices, the new Y forms a vertex cover
of G, because every edge of G must have at least one of its endpoints in Y
for Y to be a dominating set of H.
Last modified 20 December 2005