Download presentation
Presentation is loading. Please wait.
1
Chapter 10 NP-Complete Problems
2
Running times vs Input sizes
3
Decision and optimization
Decision problem: its solution has only two outcomes: yes or no Optimization problem: concern with the minimization or maximization of a certain quantity How to formulate a problem as a decision problem and an optimization problem?
4
Decision problem: ELEMENT UNIQUENESS
Input: A sequence S of integers Question: Are there two elements in S that are equal? Optimization problem: ELEMENT COUNT Output: An element in S with highest frequency
5
Decision problem: COLORING
Input: An undirected graph G=(V,E) and a positive integer k1 Question: Is G k-colorable?, i.e., can G be colored using at most k colors in such a way that no two adjacent vertices have the same color? Optimization problem: CHROMATIC NUMBER Input: An undirected graph G=(V,E) Output: The chromatic number (G) of G
6
Decision problem: CLIQUE
Input: An undirected graph graph G=(V,E) and a positive integer k Question: Does G have a clique of size k? Optimization problem: MAX-CLIQUE Input: An undirected graph G=(V,E) Output: A positive integer k, which is the maximum clique size in G
7
Decision and optimization
We usually can cast a given optimization problem as a related decision problem by imposing a bound on the value to be optimized. If an optimization problem is easy, its related decision problem is easy as well. If we can provide evidence that a decision problem is hard, we also provide evidence that its related optimization problem is hard. In the study of NP-complete problems, and computational complexity or even computability in general, it is easier to restrict one’s attention to decision problems
8
The class P Definition 10.1: Let A be an algorithm to solve a problem . We say that A is deterministic if, when presented with an instance of the problem , it has only one choice in each step throughout its execution. Thus, if A is run again and again on the same input instance, its output never changes. Definition 10.2: The class of decision problems P consists of those decision problems whose yes/no solution can be obtained using a deterministic algorithm that runs in polynomial number of steps, i.e., in O(n^k) steps, for some nonnegative integer k, where n is the input size.
9
Some decision problems in the class P
SORTING SET DISJOINTNESS SHORTEST PATH 2-COLORING 2-SAT
10
Closed under complementation
A class of problems C is closed under complementation if for any problem C the complementation of is also in C. Example: 2-COLORING and NOT-2-COLORING Theorem 10.1: The class P is closed under complementation
11
Nondeterministic algorithm
On input x, a nondeterministic algorithm consists of two phases: a) The guessing phase: An arbitrary string of character y is generated. It may correspond to a solution to the input instance or not. It may not even be in the proper format of the desired solution. It may differ from one run to another of the nondeterministic algorithm. It is only required that this string be generated in a polynomial number of steps. b) The verification phase: A deterministic algorithm verifies two things. First, it checks whether the generated solution string y is in the proper format. If it is not, the algorithm halts with the answer no. If y is on the proper format, the algorithm continues to check if it is a solution to the instance x of the problem, If it is indeed a solution to the instance x, it halts and answer yes; otherwise it halts and answer no. It is also required that this phase be completed in a polynomial number of steps.
12
The class NP Definition 10.3: The class of decision problems NP consists of those decision problems for which there exists a nondeterminstic algorithm that runs in polynomial time P is the class of decision problems that we can decide or solve using a deterministic algorithm that runs in polynomial time NP is the class of decision problems that we can check or verify their solution using a deterministic algorithm that runs in polynomial time Any problem in P is also in NP.
13
Reduce Definition 10.4: Let and ’ be two decision problems. We say that reduces to ’ in polynomial time, symbolized as poly’, if there exists a deterministic algorithm A that behaves as follows. When A is presented with an instance I of problem , it transforms it into an instance I’ of problem ’ such that the answer to I is yes iff the answer to I’ is yes. Moreover, this transformation must be achieved in polynomial time.
14
NP-hard and NP-complete
Definition 10.5: A decision problem is said to be NP-hard if for every problem ’ in NP, ’poly Definition 10.6: A decision problem is said to be NP-complete if 1) is in NP, and 2) for every problem ’ in NP, ’poly Theorem: If any NP-complete problem is polynomial-time solvable, then P=NP. Equivalently, if any problem in NP is not polynomial-time solvable, then no NP-complete problem is polynomial-time solvable.
15
The satisfiability problem
Given a boolean formula f, we say that it is in conjunctive normal form (CNF) if it is the conjunction of clauses. A clause is the disjunction of literals, where a literal is a boolean variable or its negation. A formula is said to be satisfiable if there is a truth assignment to its variables that makes it true. Decision problem: SATISFIABILITY Input: A CNF boolean formula f Question: Is f satisfiable? Theorem 10.2: SATISFIABILITY is NP-complete
16
How to prove NP-completeness
Theorem 10.3: Let , ’ and ” be three decision problems such that poly’ and ’poly”, then poly” Corollary 10.1: If and ’ are two problems in NP such that ’poly and ’ is NP-complete, then is NP-complete
17
How to prove NP-completeness
Theorem 10.3: Let , ’ and ” be three decision problems such that poly’ and ’poly”, then poly” Corollary 10.1: If and ’ are two problems in NP such that ’poly and ’ is NP-complete, then is NP-complete To prove a problem is NP-complete, we need to show 1) NP 2) there is an NP-complete problem ’ such that ’poly
18
More NP-complete problems
CLIQUE VERTEX COVER INDEPENDENT SET 3-SAT 3-COLORING 3-dimensional matching HAMILTONIAN PATH PARTITION KNAPSACK BIN PACKING SET COVER MULTIPROCESSOR SCHEDULING LONGEST PATH
19
The class co-NP The class co-NP consists of those problems whose complements are in NP Definition 10.7: A problem is complete for the class co-NP if 1) is in co-NP, and 2) for every problem ’ in co-NP, ’poly Theorem 10.5: A problem is NP-complete iff its complement is complete for the class co-NP Theorem 10.6: The problem TAUTOLOGY is complete for the class co-NP TAUTOLOGY is in P iff co-NP=P TAUTOLOGY is in NP iff co-NP=NP
20
The class NPI Theorem 10.7: If a problem and its complement are NP-complete, then co-NP=NP NPI: NP-Intermediate Theorem (Ladner): If P≠NP then there is a set A in NP such that A is not in P and A is not NP-complete.
21
The relationships between 4 classes
22
Why we learn these To become a good algorithm designer, you must understand the rudiments of the theory of NP-completeness. If you can establish a problem as NP-complete, you provide good evidence for its intractability. As an engineer, you would then do better spending your time developing an approximation algorithm or solving a tractable special case, rather than searching for a fast algorithm that solve the problem exactly. Many natural and interesting problems that on the surface seem easy are in fact NP-complete. It is important to become familiar with this class of problems
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.