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.

Slides:



Advertisements
Similar presentations
Analysis of Algorithms
Advertisements

NP-Hard Nattee Niparnan.
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,
NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Concept of Completeness and hardness for a complexity class Definition.
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 
Hardness Results for Problems P: Class of “easy to solve” problems Absolute hardness results Relative hardness results –Reduction technique.
1 NP-Completeness Objectives: At the end of the lesson, students should be able to: 1. Differentiate between class P, NP, and NPC 2. Reduce a known NPC.
The Theory of NP-Completeness
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
NP-complete and NP-hard problems
Analysis of Algorithms CS 477/677
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
P, NP, and NP-Complete Suzan Köknar-Tezel.
Hardness Results for Problems P: Class of “easy to solve” problems Absolute hardness results Relative hardness results –Reduction technique.
Hardness Results for Problems
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
Computational Complexity Polynomial time O(n k ) input size n, k constant Tractable problems solvable in polynomial time(Opposite Intractable) Ex: sorting,
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.
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.
TECH Computer Science NP-Complete Problems Problems  Abstract Problems  Decision Problem, Optimal value, Optimal solution  Encodings  //Data Structure.
CSC 413/513: Intro to Algorithms NP Completeness.
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.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
1 Design and Analysis of Algorithms Yoram Moses Lecture 11 June 3, 2010
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
Unit 9: Coping with NP-Completeness
1 Chapter 34: NP-Completeness. 2 About this Tutorial What is NP ? How to check if a problem is in NP ? Cook-Levin Theorem Showing one of the most difficult.
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.
Lecture 6 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
NP-Complete problems.
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.
NP-Algorithms Tractable vs Intractable Some problems are intractable: as they grow large, we are unable to solve them in reasonable time.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 29.
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.
NPC.
David Luebke 1 2/18/2016 CS 332: Algorithms NP Completeness Continued: Reductions.
CSC 413/513: Intro to Algorithms
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.
CSE 332: NP Completeness, Part II Richard Anderson Spring 2016.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
The Theory of NP-Completeness
NP-Complete Problems.
NP-completeness Ch.34.
P & NP.
EMIS 8373: Integer Programming
Richard Anderson Lectures NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
Lecture 2-2 NP Class.
Richard Anderson Lecture 26 NP-Completeness
ICS 353: Design and Analysis of Algorithms
Richard Anderson Lecture 25 NP-Completeness
Chapter 11 Limitations of Algorithm Power
CS 3343: Analysis of Algorithms
The Theory of NP-Completeness
RAIK 283 Data Structures & Algorithms
Presentation transcript:

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 n, then the worst-case running time is O(n c ) for constant c. problems in P are considered “tractable” (if not in P, then not tractable)

Some Examples of P and Non-P Problems SSSP problem in a directed graph, even with negative edge weights, is in P (i.e., O(VE) time) Finding the longest simple path between two nodes is Non-P because exhaustive search is “superpolynomial time”. An Euler tour of a connected, directed graph is a cycle that traverses each edge of G exactly once, although it may visit a vertex more than once. We can determine whether a graph has an Euler tour and find the edges of such a tour in O(E) time. A Hamiltonian cycle of a directed graph is a simple cycle that contains each vertex in V (each vertex only once). Determining whether a directed graph has a Hamiltonian cycle is a Non-P problem.

Complexity Classes The class NP: class of problems with solutions that can be verified in time that is polynomial in the size of the input. Imagine we are given a “certificate” of a solution (really a potential solution) of a problem. Then the problem is in NP if we can verify that the certificate is a valid solution in polynomial time. Relies on the fact that checking a solution is easier than computing it (e.g., check that a list is sorted, rather than sorting it.)

NP-Completeness The class NP-Complete (NPC): class of the “hardest” problems in NP. this class has property that if any NPC problem can be solved in polynomial time (p-time), then all problems in NP could be solved in p-time. actual status of NPC problems is unknown -No p-time algorithms have been discovered for any NPC problem - No one has been able to prove that no p-time algorithm can exist for any of them Informally, a problem is in NPC if it is in NP and is as “hard” as any problem in NP.

P, NP, NPC...how are they related? Any problem in P is also in NP, since if a problem is in P then we can solve it in polynomial-time without even being given a certificate. So P  NP. By definition, NPC  NP

P, NP, NPC...how are they related? Is NP  P ??? open problem, but intuition says no probably the most famous open problem in CS seems plausible that the ability to guess and verify a solution in p-time is more powerful than computing a solution from scratch (deterministic p-time) so...we think P ≠ NP, but no one has proven it one way or the other (despite enormous effort).

P, NP, NPC...why do we care? So...why do we care to know whether a problem is NP-Complete? if it is, then finding a p-time algorithm to solve it is unlikely. better to spend your time looking for: oan efficient approximation algorithm to find solution close to optimal oheuristics that give correct answer with high probability

P, NP, NPC...why do we care? The set of "hardest" problems, the NPC problems, includes many problems of importance in science, engineering, operations research, and business, e.g.: traveling salesman bin packing knapsack problem vertex cover (graph coloring) integer linear programming etc…

Decision Problems Showing problems are either P or NP is easier if we confine our proofs to work with decision problems (problems with yes/no answers) Example: Shortest paths general problem: What is the length of the shortest x to y path? decision problem: Is there an x to y path of length ≤ k?

Decision Problems Rationale for studying decision problems: if the decision problem is hard, the general problem is at least as hard for many problems, we only need polynomial extra time to solve the general problem decision problems are easier to study and results are easier to prove all general problems can be rephrased as decision problems

The general Traveling Salesman Problem: instance: a set of cities and the distance between each pair of cities (given as a graph). goal: Find a tour of minimum cost.

Traveling Salesman Problem (TSP) Decision Version instance: a set of cities, the distance between each pair of connected cities (given as a graph), and a bound B. question: is there a “tour” that visits every city exactly once, returns to the start, and has total distance ≤ B?

Traveling Salesman Problem (TSP) Is TSP  NP? To determine this, we need to show that we can verify a given solution (list of cities) in p-time (i.e., time O(n), where n is the number of cities). Given an encoding x of a TSP instance and a certificate y, check that each city in x is in y exactly once check that the start city in y = end city in y check that total distance ≤ B All can be done in O(n) time, so TSP  NP. Call this algorithm D TSP

Reductions Let L 1 and L 2 be two decision problems. There is a p-time reduction function, f,from L 1 to L 2 (L 1 ≤ p L 2 ) if: f transforms an input for L 1 into an input for L 2 such that the transformed input is a yes-input for L 2 iff the original input is a yes-input for L 1 f is computable in p-time (in the size of the input)

P-time Reduction Suppose we have a problem B that we know how to solve in p-time and we would like to show that a p-time algorithm exists to solve problem A. We must demonstrate a procedure that transforms any instance  of A into an instance  of B with the following characteristics: 1. The transformation is p-time 2. The answers are the same. That is, the answer for  is “yes” iff the answer for  is also “yes”

P-time Reduction We call this procedure a p-time “reduction algorithm” because it gives us a way to solve A in p-time. 1. Given an instance  of A, use a p-time reduction algorithm to transform it to an instance  of B. 2.Run the p-time decision algorithm for B on the instance  3. Use the answer for  as the answer to  In simple terms, we use the “easiness” of problem B to prove the “easiness” of problem A.

P-time Reduction We use reduction in the opposite way to show that a problem is NPC. We can use a p-time reduction to show that no known p- time algorithm exists for a particular problem B. Given an instance  of A (an NPC problem) find a p-time function to transform the instance  to an instance  of B (the unknown problem), 1.Convert the input  for A into input  for B 2.Run the decision algorithm for B on the instance  3. If B has a p-time algorithm, then using the polynomial transformation algorithm, we could convert an instance of A into an instance of B and solve A in p-time, a contradiction to A being NPC.

P-time Reduction Ex: Hamiltonian Circuit Problem to TSP The Hamiltonian Circuit Decision Problem (HC): Instance: An undirected graph G = (V, E) Question: Is there a path in G that includes every node exactly once and returns to the start? The Traveling Salesperson Decision Problem (TSP): Instance: A set of cities, distances between each city-pair, bound B Question: Is there a "tour" that visits every city exactly once, returns to the start, and has total distance ≤ B?

P-time Reduction Ex: HC to TSP Claim: HC ≤ p TSP Proof: To prove this, we need to do 2 things: 1.Define the transformation f mapping inputs for HC into inputs for TSP, and show the mapping can be computed in p-time in size of HC input. - f must map the input G = (V, E) for HC into a list of cities, distances, and a bound B for input to TSP 2.Prove the transformation is correct.

P-time Reduction Ex: HC to TSP 1. Definition of transformation f for HC ≤ p TSP: Given the HC input graph G = (V, E) with n nodes: create a set of n cities labeled with names of nodes in V. set intercity distances d(u,v) = 1if (u, v)  E 2if (u, v)  E set bound B = n (since HC circuit must be of length n) Note: f can be computed in O(n 2 ) time. Why?

P-time Reduction Ex: HC to TSP 2. Prove the transformation f for HC ≤ p TSP is correct We will prove this by showing that x  HC iff f(x)  TSP 2(a) if x  HC, then f(x)  TSP Proof of 2(a): ox  HC means HC input G = (V, E) has a hamiltonian circuit. Wlog, suppose it is the ordering (v 1, v 2,..., v n, v 1 ). oThen (v 1, v 2,..., v n, v 1 ) is also a tour of the cities in f(x), the transformed TSP instance. oThe distance of the tour (v 1, v 2,..., v n, v 1 ) is n (= B), since each consecutive pair is connected by an edge and all original edges have wt = 1. oThus, f(x)  TSP, as required.

P-time Reduction Ex: HC to TSP Proof of 2(b): if f(x)  TSP, then x  HC of(x)  TSP means there exists a tour in TSP input that has a total distance ≤ n = B. Wlog, suppose the tour goes through cities (v 1, v 2,..., v n, v 1 ). oSince all intercity distances are either 1 or 2 in f(x), and there are n intercity "legs" in the tour, each "leg" in tour must have distance 1. oSo G must have an edge between each consecutive pair of cities on the tour, and therefore (v 1, v 2,..., v n, v 1 ) must be a hamiltonian circuit in G oThus, x  HC, as required.

P-time Reduction Ex: HC to TSP Since HC ≤ p TSP, then oif there exists a p-time algorithm for TSP, then there exists a p-time algorithm for HC. (i.e., HC is no harder than TSP) oIf there does not exist a p-time algorithm for HC, then there does not exist a p-time algorithm for TSP (i.e., TSP is at least as hard as HC)

NP-Completeness Definition: A decision problem L is NP-Complete (NPC) if: 1.L  NP, and 2.for every L'  NP, L' ≤ p L (i.e., every L' in NP can be transformed to L -- so L is at least as hard as every problem in NP).

Theorem: Suppose L is NPC: oif there exists a p-time algorithm for L, then there exists a p-time algorithm for every L'  NP, i.e., P = NP oif there does not exist a p-time algorithm for L, then there does not exist a p-time algorithm for any L'  NP, i.e., P ≠ NP

Theorem 34.4: If any NPC problem is p-time solvable, Then P = NP. Equivalently, if any problem in NP is not p-time solvable, then no NPC problem is p-time solvable. Proof: Suppose that L  P and that L  NPC. Then, for any L’  NP, we know L’ ≤ p L (by defn of class NPC). Thus, we know that L’ is no harder than L, so L’  P. The second statement is the contrapositive of the first. It is a well-known logical equivalence that an implication and its contrapositive are logically equivalent. So both parts of the Theorem are true.