CSI 4105 MIDTERM SOLUTION

Similar documents
Essential facts about NP-completeness:

Chapter 2. Reductions and NP. 2.1 Reductions Continued The Satisfiability Problem (SAT) SAT 3SAT. CS 573: Algorithms, Fall 2013 August 29, 2013

NP Completeness. CS 374: Algorithms & Models of Computation, Spring Lecture 23. November 19, 2015

6.045 Final Exam Solutions

NP-Hardness reductions

CS21 Decidability and Tractability

Introduction. Pvs.NPExample

CSE 421 NP-Completeness

NP-Complete Problems. More reductions

CS 583: Algorithms. NP Completeness Ch 34. Intractability

CS 301: Complexity of Algorithms (Term I 2008) Alex Tiskin Harald Räcke. Hamiltonian Cycle. 8.5 Sequencing Problems. Directed Hamiltonian Cycle

NP and Computational Intractability

University of Toronto Department of Electrical and Computer Engineering. Final Examination. ECE 345 Algorithms and Data Structures Fall 2016

Correctness of Dijkstra s algorithm

NP-Complete Reductions 2

More on NP and Reductions

NP-Completeness Part II

Classes of Problems. CS 461, Lecture 23. NP-Hard. Today s Outline. We can characterize many problems into three classes:

CS 170, Fall 1997 Second Midterm Professor Papadimitriou

COMPSCI 611 Advanced Algorithms Second Midterm Exam Fall 2017

COMP 382. Unit 10: NP-Completeness

P P P NP-Hard: L is NP-hard if for all L NP, L L. Thus, if we could solve L in polynomial. Cook's Theorem and Reductions

Lecture 4: NP and computational intractability

Lecture 18: More NP-Complete Problems

Reductions. Example 1

NP and NP Completeness

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch]

University of Ottawa CSI 2101 Midterm Test Instructor: Lucia Moura. February 9, :30 pm Duration: 1:50 hs. Closed book, no calculators

COMPSCI 611 Advanced Algorithms Second Midterm Exam Fall 2017

NP-Completeness Review

Design and Analysis of Algorithms

NP-Complete Reductions 1

Theory of Computation Chapter 9

Complexity, P and NP

CSE 421 Introduction to Algorithms Final Exam Winter 2005

CS 5114: Theory of Algorithms. Tractable Problems. Tractable Problems (cont) Decision Problems. Clifford A. Shaffer. Spring 2014

CS 5114: Theory of Algorithms

CS21 Decidability and Tractability

1.1 P, NP, and NP-complete

NP-completeness. Chapter 34. Sergey Bereg

Polynomial-time reductions. We have seen several reductions:

COP 4531 Complexity & Analysis of Data Structures & Algorithms

CPSC 320 (Intermediate Algorithm Design and Analysis). Summer Instructor: Dr. Lior Malka Final Examination, July 24th, 2009

NP-Completeness Part II

NP-Completeness Part II

Determine the size of an instance of the minimum spanning tree problem.

NP-complete problems. CSE 101: Design and Analysis of Algorithms Lecture 20

CSCI3390-Second Test with Solutions

The Class NP. NP is the problems that can be solved in polynomial time by a nondeterministic machine.

Lecture 15 - NP Completeness 1

UC Berkeley CS 170: Efficient Algorithms and Intractable Problems Handout 22 Lecturer: David Wagner April 24, Notes 22 for CS 170

Computational Intractability 2010/4/15. Lecture 2

CSCI 1590 Intro to Computational Complexity

CS Lecture 29 P, NP, and NP-Completeness. k ) for all k. Fall The class P. The class NP

NP and Computational Intractability

CS 170 Algorithms Spring 2009 David Wagner Final

8.5 Sequencing Problems

Midterm II : Formal Languages, Automata, and Computability

CSE 4111/5111/6111 Computability Jeff Edmonds Assignment 6: NP & Reductions Due: One week after shown in slides

1. Introduction Recap

NP-Completeness. Until now we have been designing algorithms for specific problems

SAT, NP, NP-Completeness

Topics in Complexity Theory

Class Note #20. In today s class, the following four concepts were introduced: decision

Lecture #14: NP-Completeness (Chapter 34 Old Edition Chapter 36) Discussion here is from the old edition.

1 Primals and Duals: Zero Sum Games

More NP-Complete Problems

SAT, Coloring, Hamiltonian Cycle, TSP

Comp487/587 - Boolean Formulas

an efficient procedure for the decision problem. We illustrate this phenomenon for the Satisfiability problem.

NP-Complete Reductions 3

CS 3719 (Theory of Computation and Algorithms) Lectures 23-32

Undecidable Problems. Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, / 65

Discrete Optimization 2010 Lecture 10 P, N P, and N PCompleteness

Chapter 3: Proving NP-completeness Results

Limitations of Algorithm Power

NP-Completeness. Algorithmique Fall semester 2011/12

NP-complete Problems

Summer School on Introduction to Algorithms and Optimization Techniques July 4-12, 2017 Organized by ACMU, ISI and IEEE CEDA.

Theory Bridge Exam Example Questions

NP Completeness and Approximation Algorithms

IE418 Integer Programming

Some Algebra Problems (Algorithmic) CSE 417 Introduction to Algorithms Winter Some Problems. A Brief History of Ideas

IE418 Integer Programming

Algorithms: COMP3121/3821/9101/9801

CMPSCI 311: Introduction to Algorithms Second Midterm Exam

Notes for Lecture 21

CS 320, Fall Dr. Geri Georg, Instructor 320 NP 1

NP-Completeness. Subhash Suri. May 15, 2018

Chapter 34: NP-Completeness

PCPs and Inapproximability Gap-producing and Gap-Preserving Reductions. My T. Thai

Theory of Computation CS3102 Spring 2014 A tale of computers, math, problem solving, life, love and tragic death

CSCE 551 Final Exam, April 28, 2016 Answer Key

NP and NP-Completeness

Computational Complexity. IE 496 Lecture 6. Dr. Ted Ralphs

CS 6505, Complexity and Algorithms Week 7: NP Completeness

Complexity Theory: The P vs NP question

CMSC Discrete Mathematics FINAL EXAM Tuesday, December 5, 2017, 10:30-12:30

CS 70 Discrete Mathematics and Probability Theory Fall 2016 Seshia and Walrand Midterm 1 Solutions

Transcription:

University of Ottawa CSI 4105 MIDTERM SOLUTION Instructor: Lucia Moura Feb 6, 2010 10:00 am Duration: 1:50 hs Closed book Last name: First name: Student number: There are 4 questions and 100 marks total. This exam paper should have 8 pages, including this cover page. 1 Short answers / 25 2 Search versus Decision problem / 25 3 NP-completeness reductions / 25 4 Clique is NP-complete / 25 Total / 100

CSI 4105 MIDTERM SOLUTION, Feb 6, 2010 Page 2 of 8 1 Short answers 25 points The questions below are of the type true or false ; briefly justify your answer. Note: You may use any result shown in class or in homework without proving it. You may use the fact that you know particular problems are polynomial-time solvable or NP-complete. For all problems X N P, X P 3D-Matching. Justify: [TRUE] 3D-Matching is NP-complete, and the above statement says that 3D-Matching is NP-hard. If Vertex-Cover P then Sat P. [TRUE] Justify: Since Vertex-Cover is NP-complete then any problem in N P polytime reduces to it, in particular Sat. From Sat P Vertex-Cover and Vertex- Cover P it follows Sat P. If P = N P then Shortest-Path is NP-complete. [TRUE] Any problem in P is polynomial-time reducible to any other problem in P. If P = N P then the same would hold for N P. Since Shortest-Path N P, it follows that for all X N P, X P Shortest-Path. Therefore, Shortest-Path is NP-complete. It is possible that Independent-Set P and Ham-cycle P Justify: [FALSE] Similar to the second question. Since Independent-Set is NP-complete then any problem in N P polytime reduces to it, in particular Ham-cycle. From Ham-cycle P Independent-Set and Independent-Set P it follows Ham-cycle P. Which contradicts Ham-cycle P. Let X 1 and X 2 be decision problems in N P, and assume P N P. If X 1 P X 2 and X 2 P X 1, then both X 1 and X 2 are NP-complete. [FALSE] Justify: We give a counterexample. Take X 1 and X 2 in P. This implies X 1 P X 2 and X 2 P X 1. In addition, since P N P by assumption, then X 1 and X 2 are not NP-complete.

CSI 4105 MIDTERM SOLUTION, Feb 6, 2010 Page 3 of 8 2 Search versus Decision problem 25 points Recall that 3-Sat is the following decision problem: Given a formula φ which is a conjunction of k clauses over a set of variables {x 1, x 2,..., x n }, does there exist a satisfying truth assignment for φ? Consider the analogous problem 3-SatSearch that computes a satisfying assignment for φ, if one exists, or outputs φ is unsatisfiable, otherwise. Show that if 3-Sat can be solved in polynomial time, then 3-SatSearch can be solved in polynomial time. Hint 1: Do this by providing an algorithm that solves 3-SatSearch by doing calls to the polynomial-time algorithm that decides 3-Sat. Justify that your algorithm runs in polynomial time. (Note, your formulas may grow in size, and you must be careful and justify that the calls for 3-Sat have time that remain polynomial on the size of φ, even when using for your transformed larger formulas). Hint 2 : One can force the value of a variable x i in formula φ, by transforming φ into φ φ i,v, where φ i,v is given below, and uses two extra variables y and z: Forcing x i = 1: φ i,1 = (x i y z) (x i y z) (x i y z) (x i y z) Forcing x i = 0: φ i,0 = (x i y z) (x i y z) (x i y z) (x i y z) Algorithm 3-SatSearchALG(φ) Input: a fomula φ in conjunctive normal form with tree literals per clause, having n-variables and k-clauses. Output: a truth assignment to x 1, x 2..., x n that satisfies φ, or φ is not satisfiable If (3-SAT-ALG(φ)= no ) then return φ is not satisfiable else φ φ for i = 1 to n do if (3-SAT-ALG(φ φ i,1)= yes ) then φ φ φ i,1; x i 1; else φ φ φ i,0; x i 0; return (x 1, x 2,..., x n ) (continues in the next page...)

CSI 4105 MIDTERM SOLUTION, Feb 6, 2010 Page 4 of 8 Justification of polynomial running time: Assume 3-SAT-ALG is a polynomial-time algorithm that solves 3-Sat. The above algorithm repeats n times the loop. The loop consists of a constant number of operations and a call to 3-SAT-ALG which runs in time polynomial with its input. Over all the iterations, the input formula grows from φ (having n variables and k clauses) to a formula with n + 2 variables and k + 4n clauses. So each formula for which 3-SAT-ALG is called has size polynomial on the size of φ, and this algorithm runs in time polynomial on the size of this formula. So 3-SAT-ALG runs in time polynomial on the size of φ. Therefore, the above algorithm runs in polynomial time.

CSI 4105 MIDTERM SOLUTION, Feb 6, 2010 Page 5 of 8 3 NP-completeness reductions 25 points In this question, you are asked to apply some reductions discussed in class to the examples given. For problems X 2 and X 2 shown in each part below, we have studied a reduction algorithm that shows that X 1 P X 2 ; you should apply the algorithms discussed in class. Part A 10 points 3-Sat P IndependentSet Consider the following instance for 3-Sat: φ = (x 1 x 3 x 4 ) (x 1 x 2 x 4 ). Give the corresponding instance for the independent set problem Independent Set, according to the reduction algorithm for 3-Sat P IndependentSet. You need to provide (G, k), where G is a graph and k is a target size for the independent set. k = 2 Will avoid having to draw... graph description: 6 vertices, 8 edges triangle with vertices 1, 2, 3 with labels x 1, x 3, x 4 triangle with vertices 4, 5, 6 vertices with labels x 1, x 2, x 4. extra edges connecting {x 1, x 1 } and {x 4, x 4 } One possible independent set coming from the truth assignment below is vertices 1 and 6, corresponding to x 1 in the irst triangle and x 4 in the second triangle. Give a satisfying assignment for φ and show how it translate to an independent set of the right size, by marking the independent set in the picture above. x 1 = 0, x 2 = 1, x 3 = 1, x 4 = 1; independent set of size 2 above.

CSI 4105 MIDTERM SOLUTION, Feb 6, 2010 Page 6 of 8 Part B 15 points 3-Sat P DirectedHamcycle Use the same instance of 3-Sat as shown in the previous part. Give the corresponding instance for the directed Hamiltonian cycle problem, Directed- Hamcycle, according to the reduction algorithm for 3-Sat P DirectedHamcycle. You need to provide a graph. This is a bit tedious to draw in the computer... In summary, we need 4 paths with 9 vertices each. In each path, vertices 3,4 are reserved for clause 1; and 6,7 is reserved for clause 2. Follow construction in the textbook to connect 2 clause nodes to these paths, and add edges that connect the paths and add vertices s and t accordingly. My hamiltonian cycle, corresponding to the truth assignment in the previous page, in summary follows the order: s, P 1 from right to left picking up clause C 1, P 2 from left to right, P 3 from left to write, P 4 from left to right picking up clause 2, t, s. Show a hamiltonian cycle in the graph above, corresponding to a satisfying assignment for φ. You may use the same satisfying assignment as in the previous question.

CSI 4105 MIDTERM SOLUTION, Feb 6, 2010 Page 7 of 8 4 Clique is NP-complete 25 points Recall that an independent set in a graph G = (V, E) is a subset I V such that for all x, y I, {x, y} E. A clique in a graph G = (V, E ) is a subset C V such that for all x, y C with x y, {x, y} E. Consider the following decision problems: IndSet: Given (G, k), does G have an independent set of size at least k? Clique: Given (G, k), does G have a clique of size at least k? Recall the definition of the complement of a graph below, which in plain words say that you keep the same vertex set, but switch edges with non-edges. The complement of a graph G = (V, E) is a graph G = (V, E ) such that for every x, y V, x y, we have {x, y} E if and only if {x, y} E. Part A 10 points Let G = (V, E) be a graph, let G be its complement graph and let S V. Prove that S is an independent set of G if and only if S is a clique of G. Example: {1, 2, 3} is an independent set of G {1, 2, 3} is a clique of G Proof: ( ) Let S be an independent set of G. Then, for all x, y S we have {x, y} E. Then, for all x, y S we have {x, y} E. Therefore, S is a clique in G. ( ) Let S be a clique of G. Then, for all x, y S we have {x, y} E. Then, for all x, y S we have {x, y} E. Therefore, S is an independent set in G.

CSI 4105 MIDTERM SOLUTION, Feb 6, 2010 Page 8 of 8 Part B 15 points Prove that Clique is NP-complete, by proving that: (5 points) Clique N P. We can build an efficient certifier for Clique, whose inputs are (G, k) and a set of vertices S. The certifier checks that S k and that for all x, y S, x y, we have {x, y} E(G). The certifier contains at most n integers smaller than or equal to n, so its size is polynomial on the size of (G, k). This algorithm runs in time O(n 2 ). (10 points) Clique is NP-hard. Hint: Reduce from IndependentSet. You may use the result in Part A, even if you did not prove it. The reduction algorithm description for Independent-Set P Clique: The reduction algorithm takes as input (G, k), calculates G and returns (G, k). To calculate G, we go over every pair of distinct vertices x, y: if x and y are not connected by an edge in G, we make them connected by an edge in G. The polynomial time of the reduction algorithm: This runs in polynomial time, since we can calculate the complement of G in O(n 2 ). The fact that yes-instances map to yes-instances and no-instances map to no-instances: If there exists S an independent set of G of size k then by part A, S is a clique of G of size k. If there exists no independent set of size k in G, then for any set of vertices S with S = k, there exist a pair of vertices x, y with x y such that {x, y} is an edge, which implies {x, y} is not an edge in G and S is not a clique on G. Thus, there exists no clique of size k in G.... End Of MIDTERM SOLUTION