CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.

Slides:



Advertisements
Similar presentations
Analysis of Algorithms
Advertisements

NP-Hard Nattee Niparnan.
Lecture 24 Coping with NPC and Unsolvable problems. When a problem is unsolvable, that's generally very bad news: it means there is no general algorithm.
Reducibility Class of problems A can be reduced to the class of problems B Take any instance of problem A Show how you can construct an instance of problem.
What is Intractable? Some problems seem too hard to solve efficiently. Question 1: Does an efficient algorithm exist?  An O(a ) algorithm, where a > 1,
The Theory of NP-Completeness
CPE702 Complexity Classes Pruet Boonma Department of Computer Engineering Chiang Mai University Based on Material by Jenny Walter.
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
CSE 326: Data Structures Lecture #20 Really, Really Hard Problems Henry Kautz Winter Quarter 2002.
CSE332: Data Abstractions Lecture 27: A Few Words on NP Dan Grossman Spring 2010.
The Theory of NP-Completeness
Analysis of Algorithms CS 477/677
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
Toward NP-Completeness: Introduction Almost all the algorithms we studies so far were bounded by some polynomial in the size of the input, so we call them.
P, NP, and NP-Complete Suzan Köknar-Tezel.
1 The Theory of NP-Completeness 2 NP P NPC NP: Non-deterministic Polynomial P: Polynomial NPC: Non-deterministic Polynomial Complete P=NP? X = P.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
Programming & Data Structures
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Complexity Classes (Ch. 34) The class P: class of problems that can be solved in time that is polynomial in the size of the input, n. if input size is.
Advanced Algorithm Design and Analysis (Lecture 13) SW5 fall 2004 Simonas Šaltenis E1-215b
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
Prabhas Chongstitvatana1 NP-complete proofs The circuit satisfiability proof of NP- completeness relies on a direct proof that L  p CIRCUIT-SAT for every.
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
Approximation Algorithms
CSC 172 P, NP, Etc. “Computer Science is a science of abstraction – creating the right model for thinking about a problem and devising the appropriate.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
CSE332: Data Abstractions Lecture 24.5: Interlude on Intractability Dan Grossman Spring 2012.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
Unit 9: Coping with NP-Completeness
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness and course wrap up.
NP-Complete problems.
Lecture 12 P and NP Introduction to intractability Class P and NP Class NPC (NP-complete)
NP-Completeness (Nondeterministic Polynomial Completeness) Sushanth Sivaram Vallath & Z. Joseph.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
CSE 589 Part V One of the symptoms of an approaching nervous breakdown is the belief that one’s work is terribly important. Bertrand Russell.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
Lecture 25 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
1 CSE 326: Data Structures: Graphs Lecture 24: Friday, March 7 th, 2003.
NP Completeness Piyush Kumar. Today Reductions Proving Lower Bounds revisited Decision and Optimization Problems SAT and 3-SAT P Vs NP Dealing with NP-Complete.
CSC 413/513: Intro to Algorithms
Young CS 331 D&A of Algo. NP-Completeness1 NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and.
1 Ch 10 - NP-completeness Tractable and intractable problems Decision/Optimization problems Deterministic/NonDeterministic algorithms Classes P and NP.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
1 The Theory of NP-Completeness 2 Review: Finding lower bound by problem transformation Problem X reduces to problem Y (X  Y ) iff X can be solved by.
1 CSE 326: Data Structures: Graphs Lecture 23: Wednesday, March 5 th, 2003.
34.NP Completeness. Computer Theory Lab. Chapter 34P.2.
CSE 332: NP Completeness, Part II Richard Anderson Spring 2016.
The Theory of NP-Completeness
NP-completeness Ch.34.
Richard Anderson Spring 2016
Richard Anderson Lectures NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
CS154, Lecture 16: More NP-Complete Problems; PCPs
Richard Anderson Lecture 25 NP-Completeness
Richard Anderson Lecture 28 NP-Completeness
Richard Anderson Lecture 30 NP-Completeness
Prabhas Chongstitvatana
CS154, Lecture 16: More NP-Complete Problems; PCPs
CSE 589 Applied Algorithms Spring 1999
Presentation transcript:

CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007

2 Your Chance to Win a Turing Award It is generally believed that P  NP, i.e. there are problems in NP that are not in P –But no one has been able to show even one such problem! –This is the fundamental open problem in theoretical computer science –Nearly everyone has given up trying to prove it. Instead, theoreticians prove theorems about what follows once we assume P  NP ! Alan Turing ( )

3 Outline: Day 2 We’ve seen that there are a bunch of problems that seem to be hard. Today we’ll see how these problems relate to one another. Def: P 1 is reducible to P 2 if there is a conversion from an instance X of P 1 to an instance Y of P 2 such that P 1 is yes for X iff P 2 is yes for Y.

4 Clique

5 k-Clique problem Is there a clique of size k in this graph?

6 Vertex Cover problem Is there a set of vertices of size k that covers all edges?

7 How are they related? How might we reduce clique to vertex- cover? Given a clique problem (G,k), how can we turn it into a vertex cover problem? If we can do that, then we can always solve clique when we have a solution to vertex-cover!

8 Clique to Vertex Cover We can reduce Clique to Vertex Cover. Given an input (G, k) to Clique: –Build graph G complement –Let k’ = n – k Vertex Cover is “as hard as” Clique.

9  If G has a k Clique then G’ has a k’ cover: –Let C be the clique of size k. Let the cover be V-C. Then clearly every edge outside C is covered, and in G’ there are no edges in C. –Size is n-k

10  If G’ has a k’ cover then G has a k Clique: –Let D be a cover in G’ of size k’. Then there are no edges in V-D, since otherwise they wouldn’t be covered. Therefore, V-D is a clique in G. –Size of clique is n-k’.

11 TSP Travelling Salesman Problem: –Given complete weighted graph G, integer k. –Is there a cycle that visits all vertices with cost <= k? One of the canonical problems. Note difference from Hamiltonian cycle: graph is complete, and we care about weight.

12 Hamiltonian Cycle to TSP We can reduce Hamiltonian Cycle to TSP. Given graph G=(V, E): –Construct complete graph G’ on N vertices with edge weights: 1 if (u, v) in E, 2 otherwise. –Let k = N. Do example with N=5. TSP is “as hard as” Hamiltonian cycle.

13 Example B D E G C B D G C E

14 Proof If G has a Hamiltonian Cycle then G’ has a tour of weight N. –Obvious. If G’ has a tour of weight N, then G has a Hamiltonian Cycle. –Obvious.

15 Ham. Cycle to longest path Recall, Longest Path: Given directed graph G, start node s, and integer k. Is there a simple path from s of length >= k? We’ll use Directed Hamiltonian Cycle.

16 The reduction Given a directed graph G. –Pick any node as start vertex s. –Create a new node t. For every edge (u, s), add an edge (u, t). Let k = N. Draw example Longest Path is “as hard as” Ham. Cycle

17 Proof If G has a Ham. Cycle, then G’ has a path of length k from s. –Follow the cycle starting at s, at the last step go to t instead of s. If G’ has a path of length k from s, then G has a Ham. Cycle. –Path must have hit every node exactly once, and last step in path could have formed cycle in G.

18 NP-completeness We’ve seen that there are seemingly hard problems. That’s kind of interesting. The really interesting part: A large class of these are equivalent. Solving one would give a solution for all of them!

19 The pairs I picked weren’t important. There is a large class of problems, called NP-complete, such that any one can be reduced to any other. So given an algorithm for any NP-complete problem, all the others can be solved. Conversely, if we can prove there is no efficient algorithm for one, then there are no efficient algorithms for any.

20 What’s NP-complete Satisfiability of logic formulas All sorts of constraint problems All sorts of graph problems Not an overstatement to say that every area of computer science comes up against NP-complete problems.

21 What do we do about it? Approximation Algorithm: –Can we get an efficient algorithm that guarantees something close to optimal? Heuristics: –Can we get something that seems to work well most of the time? Restrictions: –Longest Path is easy on trees, for example. Many hard problems are easy for restricted inputs.

22 NP-Complete Problems The “hardest” problems in NP are called NP- complete –If any NP-complete problem is in P, then all of NP is in P Examples: –Hamiltonian circuit –Traveling salesman: find the shortest path that visits all nodes in a weighted graph (okay to repeat edges & nodes) –Graph coloring: can the vertices of a graph be colored using K colors, such that no two adjacent vertices have the same color? –Crossword puzzle construction: can a given set of 2N words, each of length N, be arranged in an NxN crossword puzzle?

23 P, NP, and Exponential Time Problems All currently known algorithms for NP-complete problems run in exponential worst case time –Finding a polynomial time algorithm for any NPC problem would mean: Diagram depicts relationship between P, NP, and EXPTIME (class of problems that provably require exponential time to solve) It is believed that P  NP  EXPTIME EXPTIME NP P NPC

24 Coping with NP-Completeness 1.Settle for algorithms that are fast on average: Worst case still takes exponential time, but doesn’t occur very often. But some NP-Complete problems are also average-time NP- Complete! 2.Settle for fast algorithms that give near-optimal solutions: In traveling salesman, may not give the cheapest tour, but maybe good enough. But finding even approximate solutions to some NP-Complete problems is NP-Complete! 3.Just get the exponent as low as possible! Much work on exponential algorithms for satisfiability: in practice can often solve circuits with 1,000+ inputs But even 2 n/100 will eventual hit the exponential curve!

25 Great Quick Reference Computers and Intractability: A Guide to the Theory of NP-Completeness, by Michael S. Garey and David S. Johnson