Problem 1. (30%)
Calculation of time complexity (3%)
Given n cities, using exhaust search to see every result takes O(n!).
Calculation of time needed to solve the problem (2%)
40 cities:40! different tours 40 add operations per each tour computing power: 0.5 trillion add operations per second: 40!∗ 40/(0.5 ∗ 1012) seconds = 2069800312653215967391200582435.6 years
Problem 2. Birds in a graph (20%)
1. (5%) The corresponding decision problem can be defined as follows: Given an undirected graph G = (V, E) with capacity ci, i∈ V , decide whether k birds can live in the given graph without fighting.
Because the maximum number of birds must be in the [maxici,∑
ici], we can solve the original optimization problem by binary search on k. That is, find the maximum k such that the decision problem returns true. The binary search requires solving the decision problem log∑
ici times, which is linear to the input size. If the decision problem belongs to P, there exists an algorithm solving it in polynomial time. By the binary search on k, we also can solve the original optimization problem in polynomial time.
2. (5%) Given any bird allocation as the certificate, we can check that no two adjacent vertices are occupied by birds in O(|V |2) and that the number of birds >= k in O(|V |). Obviously, the above verification algorithm runs in polynomial time. For a problem instance of which answer is no, it is clear that no such ceritficate exists. Therefore, the decision problem is in NP.
3. (7%) The following is a reduction from 3-CNF-SAT to the decision problem. Given a 3- CNF-SAT instance F = C1∧ C2∧ · · · ∧ Cm, where Cj is the disjunction of 3 variables, drawn form x1, x2, . . . , xl and ¯x1, ¯x2, . . . , ¯xl. Construct graph G as follows: First, create a vertex with capacity = 1 for each variable in each clause. Second, add an edge between two vertices corresponding the variables from the same clause. Finally, add an edge between every pair of vertices corresponding the variables xi and ¯xi. Now, we use the black box of the decision problem to determine whether m birds can live in G without fighting. If they can, return yes.
Otherwise, return no. (We do not require the proof of correctness in this homework problem.
The proof is similar to that of the reduction from 3-SAT to the maximum independent set, which is a well-known problem.)
Let us check the time complexity of the reduction. The first and second steps run in O(m), and the last step runs in O(m2). Therefore, 3-CNF-SAT is polynomial-time reducible to the decision problem.
4. (3%) By the fact that 3-CNF-SAT is a known NP-complete problem and the polynomial- time reduction from 3-CNF-SAT to the decision problem, the decision problem is in NP-hard.
Because the decision problem is in NP and NP-hard, the decision problem is a NP-complete problem.
Problem 3. MCS (15%)
1. (5%) Show that L∈ NP
First transform the problem into decision problem that determine whether there is an induced subgraph of both G1 and G2 with edges≥ k, a constant value. we can design an algorithm that verify H is the induced subgrapg of G, which can be done in polynomial time (O(|H| + mapping(VH → VG)) = O(n)), so totally it takes polynomial to decide that H has edges≥ k and H is induced subgrapg of oth G1 and G2.
Second we need to find the maximum k to be the Maximum Commom Subgraph, so we just need to do a for loop k = 0:min(|G1|, |G2|) and the last iteration that the decision output yes is the maximum k we want, so its still takes polynomial time to find k. Then L∈ NP . 2. (10%) Show that L∈ NP -Hard
To reduce the Maximum Clique into MCS, we just need to build a new complete graph G’, with|VG| vertices (each 2 vertices have edge), then take the input of Maximum Clique, G, and G’, as the input of MCS, then we can get the maximal k of 2 graphes, which means that G has the maximum clique with vertices = k. To build G’ only takes O(|VG|2), so the reduction can be done in polynomial time.
Since we know that Maximum Clique is in N P -Complete, L∈ NP -Hard.
L∈ NP and L ∈ NP -Hard → L ∈ NP -complete.
Problem 4. (15%)
Show that any language in NP can be decided by an algorithm running in time 2O(nk)for some constant k.
By the definition of the class NP:
A language L belongs to NP if and only if there exist a two-input polynomial-time algorithm A and a constant c such that
L={x∈ {0, 1}∗: there exists a certificate y with|y| = O(|x|c) such that A(x, y) = 1}
Then algorithm A verifies L in polynomial time.
Therefore, for a language L in N P , we can design an algorithm A2 that decides L in time 2O(nk)for some constant k.
A2
for all possible y
if A(x, y) == 1: return 1 return 0
There are 2|y|possiblities of y. |y| = O(|x|c), therefore there are 2O(|x|c)possibilities of y. And for every y, the algorithm runs A(x,y) once, in polynomial time, O(|x|t) for some constant t. So totally the runtime of the algorithm is 2O(|x|c)O(|x|t) = 2O(nc)(c2 nt) = 2O(nc)(2log2c2+tlog2n) = 2O(nk)
Problem 5. Vertex Cover(20%)
1. (4%) Find a minimum vertex cover of the graph in Figure 1.
2. No, there is no such constant k.
For n∈ N, define Gn= (Vn, En).
Vn =
∪n i=0
Vn,i
There are n! vertices in Vn,0.
For i = 1, 2, 3, ..., n, there are n!i vertices in Vn,i.
Each vertex in Vn,i are connected to i vertices in Vn,0 without duplication, so they are of degree i.
Therefore, every vertex in Vn,0is of degree n.
The figure of problem 5.1 is an example of G3. The top 6 points are in V3,1. The 6 points in the middle are in V3,0. The bottom left 2 points are in V3,3. The bottom right 3 points are in V3,2.
Since our algorithm arbitrarily pick one of the vertices that has the greatest degree, it might choose vertices in Vn,n over Vn,0, and Vn,n−1over Vn,0, and so on. Our algorithm may choose all vertices in Vn,n, Vn,n−1, Vn,n−2, ..., Vn,1 and none in Vn,0. Therefore, we would have a vertex cover of size
∑n i=1
n!
i while the minimum vertex cover is Vn,0. k∗ (n!) ≥
∑n i=1
n!
i → k ≥
∑n i=1
1
i which would approach∞ as n grows.
3. Yes. k = 2.