There are two types of problems:

Similar documents
DAA 8 TH UNIT DETAILS

NP-Complete Reductions 1

1. Introduction Recap

Essential facts about NP-completeness:

NP Complete Problems. COMP 215 Lecture 20

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

Intro to Theory of Computation

Computational Complexity and Intractability: An Introduction to the Theory of NP. Chapter 9

Easy Problems vs. Hard Problems. CSE 421 Introduction to Algorithms Winter Is P a good definition of efficient? The class P

Correctness of Dijkstra s algorithm

Limitations of Algorithm Power

NP-Complete Problems. More reductions

Polynomial time reduction and NP-completeness. Exploring some time complexity limits of polynomial time algorithmic solutions

NP and Computational Intractability

NP Completeness and Approximation Algorithms

NP-Completeness. Dr. B. S. Panda Professor, Department of Mathematics IIT Delhi, Hauz Khas, ND-16

CS 5114: Theory of Algorithms

CS Fall 2011 P and NP Carola Wenk

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

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

Graduate Algorithms CS F-21 NP & Approximation Algorithms

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

NP and Computational Intractability

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

CSE 3500 Algorithms and Complexity Fall 2016 Lecture 25: November 29, 2016

CSE 105 THEORY OF COMPUTATION

Theory of Computation Chapter 9

CSE 421 NP-Completeness

Computational Intractability 2010/4/15. Lecture 2

Design and Analysis of Algorithms

NP-Complete Problems

Algorithm Design and Analysis

Lecture 18: More NP-Complete Problems

Algorithms and Complexity Theory. Chapter 8: Introduction to Complexity. Computer Science - Durban - September 2005

Computational Complexity

NP-Completeness. NP-Completeness 1

INTRO TO COMPUTATIONAL COMPLEXITY

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

Polynomial-Time Reductions

NP-Complete Reductions 2

Polynomial-time reductions. We have seen several reductions:

P, NP, NP-Complete, and NPhard

2 COLORING. Given G, nd the minimum number of colors to color G. Given graph G and positive integer k, is X(G) k?

Introduction to Complexity Theory

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

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

Chapter 3: Proving NP-completeness Results

Introduction to Solving Combinatorial Problems with SAT

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

P,NP, NP-Hard and NP-Complete

CS21 Decidability and Tractability

Polynomial-time Reductions

Algorithms Design & Analysis. Approximation Algorithm

CS 583: Algorithms. NP Completeness Ch 34. Intractability

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

CS154, Lecture 15: Cook-Levin Theorem SAT, 3SAT

1 Primals and Duals: Zero Sum Games

COP 4531 Complexity & Analysis of Data Structures & Algorithms

Provable intractability. NP-completeness. Decision problems. P problems. Algorithms. Two causes of intractability:

CSE 135: Introduction to Theory of Computation NP-completeness

CISC 4090 Theory of Computation

CS/COE

IE418 Integer Programming

NP-Completeness. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

SAT, NP, NP-Completeness

NP-Completeness. Sections 28.5, 28.6

Spring Lecture 21 NP-Complete Problems

Complexity, P and NP

Computational complexity theory

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

Admin NP-COMPLETE PROBLEMS. Run-time analysis. Tractable vs. intractable problems 5/2/13. What is a tractable problem?

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

BBM402-Lecture 11: The Class NP

ECS122A Handout on NP-Completeness March 12, 2018

SAT, Coloring, Hamiltonian Cycle, TSP

1 Non-deterministic Turing Machine

Data Structures and Algorithms

CS20a: NP completeness. NP-complete definition. Related properties. Cook's Theorem

NP-problems continued

Reductions. Reduction. Linear Time Reduction: Examples. Linear Time Reductions

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof

DAA Unit IV Complexity Theory Overview

CS311 Computational Structures. NP-completeness. Lecture 18. Andrew P. Black Andrew Tolmach. Thursday, 2 December 2010

CSE 105 THEORY OF COMPUTATION

NP-Completeness. f(n) \ n n sec sec sec. n sec 24.3 sec 5.2 mins. 2 n sec 17.9 mins 35.

CS154, Lecture 13: P vs NP

CSE 105 Theory of Computation

CSCI3390-Lecture 17: A sampler of NP-complete problems

Automata Theory CS S-18 Complexity Theory II: Class NP

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

CS21 Decidability and Tractability

CS 350 Algorithms and Complexity

Algorithm Design and Analysis

P is the class of problems for which there are algorithms that solve the problem in time O(n k ) for some constant k.

Lecture 19: Finish NP-Completeness, conp and Friends

Computational complexity theory

6.045: Automata, Computability, and Complexity (GITCS) Class 15 Nancy Lynch

8.5 Sequencing Problems

CS 350 Algorithms and Complexity

Transcription:

Np-complete Introduction: There are two types of problems: Two classes of algorithms: Problems whose time complexity is polynomial: O(logn), O(n), O(nlogn), O(n 2 ), O(n 3 ) Examples: searching, sorting, merging, MST, etc. Problems with exponential time complexity: O(2 n ), O(n!), O(n n ), etc. Examples: TSP, n-queen, 0/1knapsack, etc. P: The set of all problems, which can be solved by deterministic algorithms in polynomial time. NP: The set of all problems which can be solved by nondeterministic algorithms in polynomial time (NP: Nondeterministic Polynomial) Software Engineering Abdelghani Bellaachia Page 1

Non-deterministic algorithms: Unlike deterministic algorithms, each operation has several outcomes Example: x = choice(1..n); x may have any value between 1 and n The time of this type of instruction is O(1). If there is a solution, the algorithm will terminate successfully; otherwise, it will terminate unsuccessfully. Example1: Searching problem: input: A(1..n) and x Output: index j such that A(j)=x if x is in A or j=0 if x does not belong to A. Ndsearch(A(1..n), x) Integer j; Begin J=choice(1..n); If A(j) =x Then Print(j); Else Print(0); Endif; End; The complexity is O(1); Software Engineering Abdelghani Bellaachia Page 2

Example2: clique problem Definition: A maximal complete subgraph of a graph G=(V,E) is a clique. Input: - a graph G=(V,E) and an integer k; Output: Determine if G has a clique of size at least k. Brute force approach: The obvious way to solve this problem would be to subject all V k test whether there is a clique. Ndclique(G,k); Integer I; X[1..n]; Begin For I=1 to k do X[I] = choice(1..n); Endfor; If(X[1], X[2],,,,, X[k])) is a clique Then print ("SUCCESS"); else print("failure"); endif; end; subsets of V with cardinality k to Software Engineering Abdelghani Bellaachia Page 3

Example3: Satisfiability: has a special role in the theory of computation. Definitions: A literal is a boolean variable (its value is either true or false). Example: A logical formula is an expression that can be constructed using literals and the operations AND and OR. The satisfiability problem is to determine if a logical formula is true for some assignment of truth values to the variables. F = (x1or x2) and (x2 or x3) and (x1or x2) 14243 14243 14243 C C 1 2 C3 where x i {0,1} 1 i 3 and C i are called clauses Is there an assignment of truth values to the variables x i 's that makes the formula F true ("Satisfies " it)? For n variables, one should consider 2 n possible assignments. Software Engineering Abdelghani Bellaachia Page 4

Ndsatisfiability(E,n) Integer i; Begin For i=1 to n do x i = choice(true, false); Endfor; If E(x 1, x 1,, x n ) is true Then Print "success"; Else Print "Failure"; Endif; End; Let n be the number of variables and p be the number of operations ANDs and Ors, the Ndsatisfiability takes O(max(n,p)) Since in general p>>n, we have O(p). NP-Complete problems: The theory of NP-completeness consists of two classes of problems: NP-complete problems NP-hard problems NP-hard problems: If an NP-hard problem can be solved in polynomial time then all NP-complete problems can be solved in polynomial time. Software Engineering Abdelghani Bellaachia Page 5

NP-complete problems: In other words: A problem id NP-hard if every problem in NP is transformable to it A problem which is NP-complete will have the property that it can be solved in polynomial time iff all other NPcomplete problems can be solved in polynomial time. In other words: A problem is NPcomplete if it is both NP_hard and NP. Note: NP-complete problems are NP-hard All NP-hard problems are not NPcomplete. Open problem: P? =NP Definition of reduction: Is reduced to P1 T P1 A2 A1 Software Engineering Abdelghani Bellaachia Page 6

A1 is defined by T and A2, where T is a polynomial transformation A1 (T,A2) P1 P2 We say that P1 is reduced to P2. If P2 is polynomial, then P1 is also polynomial. NP-complete: A problem is NP-complete: 1) if A is NP 2) every NP problem Q: Q P Cook's theorem: Satisfiability is NP-Complete Theorem: If P1 P2 and P2 P3 P1 P3 Proof: P1 T1 P2 A2 A1 P1 T2 P3 A3 Software Engineering Abdelghani Bellaachia Page 7 A2

P1 T1 P2 T2 P3 A3 A2 A1 P1 T1 T2 P3 A3 T A1 T is polynomial since T1 and T2 are polynomial P1 P3. Software Engineering Abdelghani Bellaachia Page 8

Theorem: Given a problem P, If 1) P is NP and 3) NP-complete problem Q: Q P Then P is NP-complete. Proof: We have to prove that P is NP and every NP problem R, R P - P is NP be definition - Let R be in NP R Q since Q is NP-complete by definition And Q P by definition R Q and Q P R P for every NP problem R. Corollaire: To prove a new problem P is NP-complete, we first prove that it is NP, and then find an NP-complete problem Q that reduces to P. SAT k-clique 3-satisfiability Vertex cover Direct HC Undirect HC TSP Software Engineering Abdelghani Bellaachia Page 9

Example: Node cover problem: Definition: Given a graph G=(V,E), a subset S of V is a node cover of G iff all edges are incident to at least on vertex in S. 1 2 3 S = {1,2} 5 4 Software Engineering Abdelghani Bellaachia Page 10