The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.

Slides:



Advertisements
Similar presentations
Problems and Their Classes
Advertisements

NP-Hard Nattee Niparnan.
1 NP-completeness Lecture 2: Jan P The class of problems that can be solved in polynomial time. e.g. gcd, shortest path, prime, etc. There are many.
NP-Completeness: Reductions
NP and NP Complete. Definitions A problem is in the class P if there is a polynomial time solution to the problem A problem is in the class NP if there.
The Theory of NP-Completeness
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
© The McGraw-Hill Companies, Inc., Chapter 8 The Theory of NP-Completeness.
CSC5160 Topics in Algorithms Tutorial 2 Introduction to NP-Complete Problems Feb Jerry Le
1 Optimization problems such as MAXSAT, MIN NODE COVER, MAX INDEPENDENT SET, MAX CLIQUE, MIN SET COVER, TSP, KNAPSACK, BINPACKING do not have a polynomial.
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
The Theory of NP-Completeness
NP-Complete Problems Problems in Computer Science are classified into
88- 1 Chapter 8 The Theory of NP-Completeness P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class.
Analysis of Algorithms CS 477/677
Chapter 11: Limitations of Algorithmic Power
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
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.
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
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.
1 UNIT -6 P, NP, and NP-Complete. 2 Tractability u Some problems are intractable: as they grow large, we are unable to solve them in reasonable time u.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
CSCE350 Algorithms and Data Structure
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.
Lecture 22 More NPC problems
Summary  NP-hard and NP-complete  NP-completeness proof  Polynomial time reduction  List of NP-complete problems  Knapsack problem  Isomprphisim.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
1 Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples: b number of comparisons needed to find the.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
The Theory of Complexity for Nonpreemptive Scheduling 1.
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 How to prove that a problem is NPC. 2 Cook Cook showed the first NPC problem: SAT Cook received Turing Award in 1982.
Unit 9: Coping with NP-Completeness
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
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.
Instructor Neelima Gupta Table of Contents Class NP Class NPC Approximation Algorithms.
Design and Analysis of Algorithms - Chapter 101 Our old list of problems b Sorting b Searching b Shortest paths in a graph b Minimum spanning tree b Primality.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
NPC.
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
COMPLEXITY. Satisfiability(SAT) problem Conjunctive normal form(CNF): Let S be a Boolean expression in CNF. That is, S is the product(and) of several.
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.
COMPLEXITY. Satisfiability(SAT) problem Conjunctive normal form(CNF): Let S be a Boolean expression in CNF. That is, S is the product(and) of several.
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.
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
CSE 332: NP Completeness, Part II Richard Anderson Spring 2016.
Advanced Algorithms NP-hard and NP-Complete Problems Instructor: Saeid Abrishami Ferdowsi University of Mashhad.
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
More NP-Complete and NP-hard Problems
Chapter 10 NP-Complete Problems.
Richard Anderson Lecture 26 NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
Hard Problems Introduction to NP
ICS 353: Design and Analysis of Algorithms
Richard Anderson Lecture 28 NP-Completeness
Chapter 11 Limitations of Algorithm Power
NP-Complete Problems.
CS 3343: Analysis of Algorithms
The Theory of NP-Completeness
Our old list of problems
Presentation transcript:

The Theory of NP-Completeness 1

Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking stage of a nondeterministic algorithm is of polynomial time-complexity, then this algorithm is called an NP (nondeterministic polynomial) algorithm. NP problems : (must be decision problems) e.g. searching, MST sorting satisfiability problem (SAT) traveling salesperson problem (TSP) 3- 2

3- 3 N ondeterministic operations and functions Choice(S) : arbitrarily chooses one of the elements in set S Failure : an unsuccessful completion Success : a successful completion Nonderministic searching algorithm: j ← choice(1 : n) /* guessing */ if A(j) = x then success /* checking */ else failure 3- 3

3- 4 A nondeterministic algorithm terminates unsuccessfully iff there exist no a set of choices leading to a success signal. The time required for choice(1 : n) is O(1). A deterministic interpretation of a non- deterministic algorithm can be made by allowing unbounded parallelism in computation. 3- 4

3- 5 Nondeterministic sorting B ← 0 /* guessing */ for i = 1 to n do j ← choice(1 : n) if B[j] ≠ 0 then failure B[j] = A[i] /* checking */ for i = 1 to n-1 do if B[i] > B[i+1] then failure success 3- 5

NP : the class of decision problem which can be solved by a non-deterministic polynomial algorithm. P: the class of problems which can be solved by a deterministic polynomial algorithm. NP-hard: the class of problems to which every NP problem reduces. NP-complete (NPC): the class of problems which are NP-hard and belong to NP. 3- 6

Some concepts of NPC Definition of reduction: Problem A reduces to problem B (A  B) iff A can be solved by a deterministic polynomial time algorithm using a deterministic algorithm that solves B in polynomial time. B is harder. Up to now, none of the NPC problems can be solved by a deterministic polynomial time algorithm in the worst case. It does not seem to have any polynomial time algorithm to solve the NPC problems. 3- 7

The theory of NP-completeness always considers the worst case. The lower bound of any NPC problem seems to be in the order of an exponential function. Not all NP problems are difficult. (e.g. the MST problem is an NP problem.) If A, B  NPC, then A  B and B  A. Theory of NP-completeness If any NPC problem can be solved in polynomial time, then all NP problems can be solved in polynomial time. (NP = P) 3- 8

Decision problems The solution is simply “ Yes ” or “ No ”. Optimization problems are more difficult. e.g. the traveling salesperson problem Optimization version: Find the shortest tour Decision version: Is there a tour whose total length is less than or equal to a constant c ? 3- 9

Solving an optimization problem by a decision algorithm : Solving TSP optimization problem by decision algorithm : Give c 1 and test (decision algorithm) Give c 2 and test (decision algorithm)  Give c n and test (decision algorithm) We can easily find the smallest c i 3- 10

The satisfiability problem The logical formula : x 1 v x 2 v x 3 & - x 1 & - x 2 the assignment : x 1 ← F, x 2 ← F, x 3 ← T will make the above formula true. (-x 1, -x 2, x 3 ) represents x 1 ← F, x 2 ← F, x 3 ← T 3- 11

If there is at least one assignment which satisfies a formula, then we say that this formula is satisfiable; otherwise, it is unsatisfiable. An unsatisfiable formula : x 1 v x 2 & x 1 v -x 2 & -x 1 v x 2 & -x 1 v -x

Definition of the satisfiability problem: Given a Boolean formula, determine whether this formula is satisfiable or not. A literal : x i or -x i A clause : x 1 v x 2 v -x 3  C i A formula : conjunctive normal form C 1 & C 2 & … & C m 3- 13

Cook ’ s theorem NP = P iff the satisfiability problem is a P problem. SAT is NP-complete. It is the first NP-complete problem. Every NP problem reduces to SAT

The vertex cover problem Def: Given a graph G=(V, E), S is the node cover if S  V and for every edge (u, v)  E, either u  S or v  S or both. node cover : {1, 3} {5, 2, 4} Decision problem :  S   S   K  3- 15

Chromatic number decision problem (CN) Def: A coloring of a graph G=(V, E) is a functionf : V  { 1, 2, 3, …, k } such that if (u, v)  E, then f(u)  f(v). The CN problem is to determine if G has a coloring for k. E.g. Satisfiability with at most 3 literals per clause (SATY)  CN. 3-colorable f(a)=1, f(b)=2, f(c)=1 f(d)=2, f(e)=

Set cover decision problem Def: F = {S i } = { S 1, S 2, …, S k } S i = { u 1, u 2, …, u n } T is a set cover of F if T  F and S i = S i The set cover decision problem is to determine if F has a cover T containing no more than c sets. example F = {(a 1, a 3 ), (a 2, a 4 ), (a 2, a 3 ), (a 4 ), (a 1, a 3, a 4 )} s 1 s 2 s 3 s 4 s 5 T = { s 1, s 3, s 4 } set cover T = { s 1, s 2 } set cover, exact cover 3- 17

Sum of subsets problem Def: A set of positive numbers A = { a 1, a 2, …, a n } a constant C Determine if  A  A  a i = C e.g. A = { 7, 5, 19, 1, 12, 8, 14 } C = 21, A = { 7, 14 } C = 11, no solution Exact cover  sum of subsets

Partition problem Def: Given a set of positive numbers A = { a 1,a 2, …,a n }, determine if  a partition P,   a i =  a i i  p i  p e. g. A = {3, 6, 1, 9, 4, 11} partition : {3, 1, 9, 4} and {6, 11} sum of subsets  partition 3- 19

Bin packing problem Def: n items, each of size c i, c i > 0 bin capacity : C Determine if we can assign the items into k bins,   c i  C, 1  j  k. i  bin j partition  bin packing

Max clique problem Def: A maximal complete subgraph of a graph G=(V,E) is a clique. The max (maximum) clique problem is to determine the size of a largest clique in G. e. g. SAT  clique decision problem. maximal cliques : {a, b}, {a, c, d} {c, d, e, f} maximum clique : (largest) {c, d, e, f} 3- 21

Hamiltonian cycle problem Def: A Hamiltonian cycle is a round trip path along n edges of G which visits every vertex once and returns to its starting vertex. e.g. Hamiltonian cycle : 1, 2, 8, 7, 6, 5, 4, 3, 1. SAT  directed Hamiltonian cycle ( in a directed graph ) 3- 22

Traveling salesperson problem Def: A tour of a directed graph G=(V, E) is a directed cycle that includes every vertex in V. The problem is to find a tour of minimum cost. Directed Hamiltonian cycle  traveling salesperson decision problem

0/1 knapsack problem Def: n objects, each with a weight w i > 0 a profit p i > 0 capacity of knapsack : M Maximize  p i x i 1  i  n Subject to  w i x i  M 1  i  n x i = 0 or 1, 1  i  n Decision version : Given K,   p i x i  K ? 1  i  n Knapsack problem : 0  x i  1, 1  i  n. partition  0/1 knapsack decision problem

Toward NP-Completeness: Cook’s theorem: The SAT problem is NP-complete. Once we have found an NP-complete problem, proving that other problems are also NP-complete becomes easier. Given a new problem Y, it is sufficient to prove that Cook’s problem, or any other NP-complete problems, is polynomially reducible to Y. Known problem -> unknown problem 3- 25

NP-Completeness Proof The following problems are NP-complete: vertex cover(VC) and clique. Definition:  A vertex cover of G=(V, E) is V’  V such that every edge in E is incident to some v  V’. Vertex Cover(VC): Given undirected G=(V, E) and integer k, does G have a vertex cover with  k vertices? CLIQUE: Does G contain a clique of size  k? 3- 26

NP-Completeness Proof: Vertex Cover(VC) Problem: Given undirected G=(V, E) and integer k, does G have a vertex cover with  k vertices? Theorem: the VC problem is NP-complete. Proof: (Reduction from CLIQUE, i.e., given CLIQUE is NP- complete) VC is in NP. This is trivial since we can check it easily in polynomial time. Goal: Transform arbitrary CLIQUE instance into VC instance such that CLIQUE answer is “yes” iff VC answer is “yes”

NP-Completeness Proof: Vertex Cover(VC) Claim: CLIQUE(G, k) has same answer as VC (, n-k), where n = |V|. Observe: There is a clique of size k in G iff there is a VC of size n-k in

NP-Completeness Proof: Vertex Cover(VC) Observe: If D is a VC in, then has no edge between vertices in V-D. So, we have k-clique in G n-k VC in Can transform in polynomial time

NP-Completeness Proof: CLIQUE Problem: Does G=(V,E) contain a clique of size k? Theorem: Clique is NP-Complete. (reduction from SAT) Idea: Make “column” for each of k clauses. No edge within a column. All other edges present except between x and x’ 3- 30

NP-Completeness Proof: CLIQUE Example: G = G has m-clique (m is the number of clauses in E), iff E is satisfiable. (Assign value 1 to all variables in clique) 3- 31