0% found this document useful (0 votes)
9 views

IITKGP_Assignment4_solution4

Uploaded by

dillip.rout
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

IITKGP_Assignment4_solution4

Uploaded by

dillip.rout
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

CS60007 Algorithm Design and Analysis 2018

Solution of Assignment 4
Palash Dey and Swagato Sanyal
Indian Institute of Technology, Kharagpur

Please submit the solutions of problem 1, 5, and 12. The deadline is November
12, 2018 in the class.

General Instructions
B Please prove correctness of every algorithm you design.

B If not stated otherwise, please ensure that your algorithm runs in polynomial time.

B If not stated otherwise, please design a deterministic algorithm.

B If not stated otherwise, please assume that n to be the size (the number of bits) of
the input instance.

B If not stated otherwise, please assume that the graphs under consideration are finite,
weighted, and directed graphs which does not contain any self loop.

B We have not defined some standard problems. You are expected to find the problem
statements (from Google say) by yourself.

1. Let n denotes the number of vertices in the graph. Prove that if there exists an kn
factor approximation algorithm for the Travelling Salesman problem for any positive
integer k, then P = NP.

Proof. Let k be any positive integer. We will show that if there exists a kn factor
approximation algorithm for the Travelling Salesman problem, then there exists a
polynomial time algorithm for the Hamiltonian Cycle problem on undirected graphs.
Let us assume that there exists a kn factor approximation algorithm A for the Trav-
elling Salesman problem.

1
Let G be an instance of the Hamiltonian Cycle problem. We construct another graph
H from G as follows. We have V[H] = V[G]; that is, the set of vertices in H is the
same as in G. The graph H is a complete graph. For any two vertices u, v ∈ V[H] with
u 6= v, we define the weight w({u, v}) of the edge {u, v} in H to be 1 if {u, v} ∈ E[G];
otherwise we define the weight w({u, v}) of the edge {u, v} in H to be n2 kn . We now
claim that there exists a Hamiltonian cycle in G if and only if there exists a Travelling
Salesman tour in H of weight n. To prove this, in one direction, let us assume that
there exists a Hamiltonian cycle C in G. Then the weight of the tour C in H is n.
For the other direction, let us assume that there exists a Travelling Salesman tour T
in H of weight n. Then T forms a Hamiltonian cycle in G since if any edge in T is
not present in G, then the weight of the tour T in H would be at least n2 kn which
is strictly greater than n for any positive integer k. This proves the claim. Moreover,
from the proof of the claim it also follows that if there is no Hamiltonian cycle in G
then the weight of any Travelling Salesman tour in H is at least n2 kn .
Since n2 kn can be computed in polynomial in n time, the graph H can be constructed
in polynomial in n time from G. We run the algorithm A on H and output that G has
a Hamiltonian Cycle if and only if A outputs a tour of weight at most nkn . We now
prove correctness of our algorithm.
If G has a Hamiltonian cycle, then it follows from the above claim that H has a
Travelling Salesman tour of weight n. Hence, by the definition of an approximation
factor, A returns a Travelling Salesman tour in H of weight at most nkn and hence,
in the case when G has a Hamiltonian cycle, our algorithm outputs correctly. If G
does not have any Hamiltonian cycle, then it follows from the above claim that any
Travelling Salesman tour in H has weight at least n2 kn . In particular, the Travelling
Salesman tour returned by the algorithm A in this case has weight at least n2 kn
which is strictly greater than nkn . Thus our algorithm correctly outputs also in the
case when G does not have any Hamiltonian cycle. This concludes the proof of
correctness of our algorithm. Our algorithm runs in polynomial time since H can be
constructed form G in polynomial time and the algorithm A runs in polynomial time.
Since the Travelling Salesman problem is NP-complete, we have P = NP.

2. Design a 87 factor approximation algorithm for the MAX3SAT problem. [Hint: try
greedy approach.]
3. Design a O(log n) factor approximation algorithm for the Set Cover problem. [Hint:
try greedy approach.]
4. Design a 2 factor approximation algorithm for the Vertex Cover problem. [Hint: try
to find polynomial time computable lower bound on the size of a minimum vertex
cover.]
5. Design a 2 factor approximation algorithm for the Bin Packing problem. [Hint: This
is Problem 35-1 in the CLRS book. Follow the guideline provided in CLRS.]

2
P
Proof. Let si , i ∈ [n] with si ∈ (0, 1) be the set of objects. Let S = n i=1 si . Since
the capacity of every bin is 1, we have OPT = dSe. We use the first fit algorithm.
Concretely, we iteratively pick objects si for i ∈ [n] (in any order) and if there exists
a bin which can hold si (that is the sum of weights of the objects the bin is currently
holding is at most 1 − si ), then we put si to that bin; otherwise we put si is a new
empty bin. We claim that there is at most one bin which holds a total weight of at
most 21 during the run of the algorithm. The claim is clearly true after assigning the
first item (since the number of bins is 1 then). Suppose not, then let us assume that
the first time when the claim does not hold is after putting the object s` . Since the
claim was true before putting the object s` , the object must have been put in a new
bin and the new bin must contain objects of weight at most 12 ; that is s` 6 12 since s`
is the only object in the new bin. Since s` has been assigned in a new bin and s` 6 12 ,
every bin except the new bin must contain objects of total weight strictly more than 12
(otherwise, if there was a bin with total weight at most 21 , then our algorithm would
have assigned s` to that bin and never acquired a new bin). We now claim that the
number of bin used by the first fit algorithm, denoted by ALG, is at most d2Se. If
2S is a integer, then it follows from the claim above that ALG 6 2S. On the other
hand, if 2S is not an integer, then we have ALG 6 b2Sc + 1 6 d2Se from the claim
above. Since d2Se 6 2dSe 6 2OPT, the first fit algorithm is a 2 factor approximation
algorithm.

6. Design a FPTAS for the 0/1-Knapsack problem.


7. Prove that if there exists an α factor
√ approximation algorithm for the Maximum
Clique problem, then there exists a α factor approximation algorithm for the Maxi-
mum Clique problem for any constant α. Deduce from this that if if there exists an α
factor approximation algorithm for the Maximum Clique problem, then there exists
a PTAS for the Maximum Clique problem. [Hint: Use hint from Problem 35-2 in the
CLRS book.]
8. Prove that if there exists a FPTAS for the Vertex Cover problem, them P = NP.
9. Design a randomized 12 factor approximation algorithm for the Maximum Cut prob-
lem. Deduce from this that for every graph, there exists a cut consisting of at least
half the edges in the graph.
10. Design a deterministic 12 factor approximation algorithm for the Maximum Cut prob-
lem. [Hint: try greedy approach.]
11. We know that CNF-SAT is NP-complete due to the famous Cook-Levin Theorem. De-
sign a polynomial time algorithm for DNF-SAT.
12. We know that 3SAT is NP-complete. Design a polynomial time algorithm for 2SAT.
Refer to https://www.iitg.ac.in/deepkesh/CS301/assignment-2/2sat.pdf

You might also like