Docsity

Test 5 Sample - Design and Analysis-Algorithms | CS 3510, Exams of Algorithms and Programming

Toggle sidebar
bg1
CS 3510: Design and Analysis of Algorithms
Test 5 sample
You can assume the following:
•The k-COLORING problem is the following: Given an undirected graph G= (V , E) and an integer k≥3, is there
a way to label the vertices from {1, . . . , k}such that adjacent vertices do not get the same value?
The k-COLORING problem is N P-Complete.
•The SAT problem is the following: Given a Boolean formula in conjunctive normal form, is there a truth assignment
to its variables that make the formula evaluate to true?
The SAT problem is NP -Complete.
•Evaluating a Boolean formula given a truth assignment to its variables is in P.
1. A bipartite graph G= (V, E) is an undirected graph whose vertex set Vcan be partitioned into two sets V1and V2
such that every edge in Ehas one end in V1and the other end in V2.
A matching Min Gis a subset of the edges such that each vertex appears in at most one edge in M.
Given a bipartite graph G= (V, E) and a matching Min G, design a linear time algorithm to decide if Mis a
maximum matching in G. Why is your algorithm correct? Why does your algorithm run in linear time?
(Hint: Construct a network and a suitable flow from Gand M.)
Construct a network from Gas in the reduction from bipartite matching to maximum flow problem. Define a flow f
on this network as follows: for every matched edge (u, v), define f(s, u) = f(u, v ) = f(v, t) = 1. This is a valid
flow. By the correctness argument in the above mentioned reduction, this flow value is the same as the cardinality of
the matching. That is, this flow is maximum iff the given matching is maximum. Now, test if this flow is maximum
by: (a) constructing a residual network, and (b) testing if there is a directed path from sto tin the residual network.
2. Answer TRUE/FALSE with a justification: If every problem in N P is NP -Complete then P=N P .
True. According to the hypothesis, CNFSAT which is NP -Complete is reducible to a problem Lin P and hence every
problem in N P is reducible to the problem Lin P.
3. A Boolean formula over the variables X1, . . . , Xnis a tautology if it evaluates to true for all truth assignments for the
variables.
(a) Given a conjunctive-normal form Boolean formula F, give a polynomial time algorithm to decide if Fis NOT a
tautology.
Fis not a tautology iff there is a truth assignment for the variables that makes the formula evaluate to false.
For a conjunctive normal form formula this can be tested by finding a clause in which no variable appears both
as a positive literal and a negative literal.
(b) Given a conjunctive normal form Boolean formula F, is there a polynomial time algorithm to decide if Fis a
tautology? Why? or Why not?
The answer is yes. Run the polynomial time algorithm to decide if an input formula is not a tautology and negate
the answer.
4. Consider the following exam-scheduling problem. Let F={F1, F2, . . . , Fk}be the set of final examinations to be
scheduled. Let S1, S2, . . . , Smbe mstudents taking the exams. For all 1 ≤i≤m, let Ei⊆Fbe the set of exams
that student Siis taking. A schedule of these exams into time slots so that no student is required to take two exams in
the same slot is a valid schedule. Let hbe the number of slots available. The exam-scheduling problem is to determine
if a valid schedule exists that uses only htime slots.
Show that the valid scheduling problem is N P-Complete.
1
pf2

Partial preview of the text

Download Test 5 Sample - Design and Analysis-Algorithms | CS 3510 and more Exams Algorithms and Programming in PDF only on Docsity!

CS 3510: Design and Analysis of Algorithms

Test 5 sample

You can assume the following:

  • The k-COLORING problem is the following: Given an undirected graph G = (V, E) and an integer k ≥ 3, is there a way to label the vertices from { 1 ,... , k} such that adjacent vertices do not get the same value? The k-COLORING problem is N P-Complete.
  • The SAT problem is the following: Given a Boolean formula in conjunctive normal form, is there a truth assignment to its variables that make the formula evaluate to true? The SAT problem is N P-Complete.
  • Evaluating a Boolean formula given a truth assignment to its variables is in P.
  1. A bipartite graph G = (V, E) is an undirected graph whose vertex set V can be partitioned into two sets V 1 and V 2 such that every edge in E has one end in V 1 and the other end in V 2. A matching M in G is a subset of the edges such that each vertex appears in at most one edge in M. Given a bipartite graph G = (V, E) and a matching M in G, design a linear time algorithm to decide if M is a maximum matching in G. Why is your algorithm correct? Why does your algorithm run in linear time? (Hint: Construct a network and a suitable flow from G and M .) Construct a network from G as in the reduction from bipartite matching to maximum flow problem. Define a flow f on this network as follows: for every matched edge (u, v), define f (s, u) = f (u, v) = f (v, t) = 1. This is a valid flow. By the correctness argument in the above mentioned reduction, this flow value is the same as the cardinality of the matching. That is, this flow is maximum iff the given matching is maximum. Now, test if this flow is maximum by: (a) constructing a residual network, and (b) testing if there is a directed path from s to t in the residual network.
  2. Answer TRUE/FALSE with a justification: If every problem in N P is N P-Complete then P = N P.

True. According to the hypothesis, CNFSAT which is N P-Complete is reducible to a problem L in P and hence every problem in N P is reducible to the problem L in P.

  1. A Boolean formula over the variables X 1 ,... , Xn is a tautology if it evaluates to true for all truth assignments for the variables.

(a) Given a conjunctive-normal form Boolean formula F , give a polynomial time algorithm to decide if F is NOT a tautology. F is not a tautology iff there is a truth assignment for the variables that makes the formula evaluate to false. For a conjunctive normal form formula this can be tested by finding a clause in which no variable appears both as a positive literal and a negative literal. (b) Given a conjunctive normal form Boolean formula F , is there a polynomial time algorithm to decide if F is a tautology? Why? or Why not? The answer is yes. Run the polynomial time algorithm to decide if an input formula is not a tautology and negate the answer.

  1. Consider the following exam-scheduling problem. Let F = {F 1 , F 2 ,... , Fk} be the set of final examinations to be scheduled. Let S 1 , S 2 ,... , Sm be m students taking the exams. For all 1 ≤ i ≤ m, let Ei ⊆ F be the set of exams that student Si is taking. A schedule of these exams into time slots so that no student is required to take two exams in the same slot is a valid schedule. Let h be the number of slots available. The exam-scheduling problem is to determine if a valid schedule exists that uses only h time slots. Show that the valid scheduling problem is N P-Complete.

(Hint: Give a reduction from the k-COLORING problem to the exam-scheduling problem.) Given a graph G = (V, E) and an integer k output the following instance of the exam-scheduling problem: F = V. Let the edges in the graph be e 1 , e 2 , · · · , em. The number of students m is the number of edges. For 1 ≤ i ≤ m, let Ei be the endpoints of the edge ei. Let h = k.

  1. The CLIQUE problem is the following:

INPUT: An undirected graph G = (V, E) with n vertices and an integer 1 ≤ k ≤ n. PROBLEM: Is there a clique (that is, a complete subgraph) of size ≥ k in G? Given a conjunctive normal form formula F with 3 literals per clause, create a graph G as follows: For all the literals in each clause create a vertex. Label the vertices with the literals. Add an edge between two nodes iff: (a) they do not belong to the same clause, and (b) the labels are not negations of each other.