np-completeness presented by tushar kumar j. ritesh bagga

21
NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA

Upload: victor-montgomery

Post on 13-Jan-2016

216 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA

NP-COMPLETENESS

PRESENTED BY

TUSHAR KUMAR J.

RITESH BAGGA

Page 2: NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA

OVERVIEW

Introduction.Examples of exponential-time

algorithms.NPC Class of algorithms.Approaches to tackle NPC problems.Polynomial Reductions.Examples of NPC Problems.

Page 3: NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA

Introduction

Most of the algorithms, we came across so far takes either logarithmic time (O(logn)), linear time (O(n)) or polynomial time (O(nk), k=2,3,4…).

But there are some problems, for which we do not have polynomial algorithm. Such problems falls under the Super polynomial category (taking exponential time).

The following graph shows a clear distinction between the various categories under which the algorithm falls according to the running time they require -

Page 4: NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA

Introduction (1)

2n

n10

n3

n2

n

Polynomial-time

Exponential-time

n

F(n)

Page 5: NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA

Examples of problem falling under the Exponential time

category Some of the simple problems, which are very

similar to problems that requires polynomial time falling under the exponential time category are:

1. Longest simple path problem (similar to Shortest path problem, which requires polynomial time) suspected to require exponential time, since there is no known polynomial algorithm.

2. Hamiltonian tour – visiting all the vertices in a graph exactly once, by passing through edges more than once, requires exponential time (similar to Euler tour problem – visiting all the vertices in a graph, by passing through each edge exactly once, requires polynomial time).

Page 6: NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA

Examples of problem falling under the Exponential time

category (1)3. A good example of a problem which cannot be solved in

polynomial time is Satisfiability problem. Satisfiability problem (SAT problem)

Basically a problem from Logic. Generally described using Boolean formula. A Boolean formula involves AND, OR, NOT operators and

some variables. Ex: (x or y) and (x or z), where x, y, z are boolean

variables. Problem Definition – Given a boolean formula containing

‘n’ boolean variables, can you assign some values to these variables so that it can be true?????

Page 7: NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA

Examples of problem falling under the Exponential time

category (2) We generally deal with SAT problems having 2 or 3 boolean

variables in a clause. They are called as 2SAT and 3SAT problems respectively.

Ex: 2SAT problem – (x or y) and (y or z) 3SAT problem – (x or y or z) and (~x or y or ~z) where x, y, z, ~x (complement of x) and ~z (complement of z) (…………….) denotes a clause. In the above example for

2SAT problem, the clauses are (x or y) and (y or z).

2SAT problems can be solved in polynomial time. But 3SAT problems doesn’t have any known polynomial time

algorithm and it is historically found as the first problem which requires exponential time.

Page 8: NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA

Various classes of problems

The problems generally falls into one of the three classes – Polynomial (P), Non-deterministic Polynomial (NP) and NP Completeness (NPC).

The figure following represents these classes:

Polynomial Class

Non-Polynomial Class

Exponential Class

Non-Polynomial Complete

Page 9: NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA

Various classes of problems (1)

P = the class of problems that can be solved in polynomial time.

NP = the class of problems whose solutions can be verified in polynomial time.

NPC = the class of problems which belongs to NP and atleast as hard as all other problems in NP.

Page 10: NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA

Approaches to tackle NPC problems

There are three approaches to tackle NPC problems. They are Decision problems –

Easy to solve when compare to other problems. Decision problems output the results as boolean value

(Yes or No) Hence we convert all the problems into decision

problems.

Problem

Yes

NoDecision version of problem

Page 11: NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA

Approaches to tackle NPC problems (1)

Reduction Problems – A means of comparing two problems. Suppose A and B are two problems, given that B is difficult. We suspect A is difficult. To confirm, we try to solve B using A as subroutine. For example: We know that the Longest Path Problem (LPP) is hard and

we can solve Hamiltonian path problem using LPP as subroutine. So we can conclude HPP is harder than LPP.

Page 12: NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA

Approaches to tackle NPC problems (2)

Encodings – Encoding is a process of converting a problem into a language

is called as encoding. Strings are defined as sequence of alphabets (∑). Languages are set of strings (i.e. we are interested in

languages with unlimited set of strings. Some examples – 3SAT equivalent to { set of all formulas such

that each formula is in correct syntax and it is satisfiable. Suppose we have 20 variables, so we can use 0,1 to represent

these 20 variables, # to represent OR and $ to represent AND. Thus we can encode these formulas using set of the above characters { all strings over = { 0,1,#,$}}

Now the problem of solving 3SAT (any decision problem can be reduced to language recognition problem).

Page 13: NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA

Polynomial Reductions Given two problems P1 and P2, if all strings in P1 can

be mapped to strings in P2 using a mapping algorithm in polynomial time. we can say that P2 is polynomially harder than P1.

P1 <=p P2

Formal definition of NP- complete – A problem P belongs to NP- complete if it belongs

to the class NP and P1 belongs to NP, P1 <=p P2

Page 14: NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA

Polynomial Reductions (1)

Polynomial-time

Matching-algorithm

P1 P2

Σ* Σ*

P1 P2=<

Page 15: NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA

Cook’s Theorem

Stephen Cook founded the first NP- complete problem (3SAT) .

3SAT problem was proved to be the most difficult problem in the class of NP- complete problems.

To prove a new problem p is NP- complete, we need to

1. prove p is in NP2. Any known NP- complete problem p

≤p

Page 16: NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA

Examples of NPC problems

3SAT – We will prove that it is a NPC problem. Suppose we have ‘m’ clauses with ‘n’ variables (3 in each clause), so we need to try all possible sets of solutions. Thus we have 2n sets of possible solutions. So it is a NPC problem.

Clique – It is a subgraph of a graph which contains all possible edges between each pair of vertices in the subgraph. To prove clique is a NPC problem, we compare with 3SAT problem. It can be reduced to decision problem, where input : G,K

output: Yes, if clique with atleast ‘K’ nodes exists, No, otherwise

Page 17: NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA

Examples of NPC problems (1)

For example: (x1 OR ~x2 OR ~x3) AND (~x1 OR x2 OR X3) AND (x1 OR x2 OR x3). This is a 3SAT problem and we will create a graph from it. We will put all possible edges, except edges in the same clause and between a variable and its negation.

Graph showing Clique

Page 18: NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA

Examples of NPC problems (2)

X1

X3

X1

X2

X3

X2 X

3

X2

X1

Note :Red nodes denotes negation.

Page 19: NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA

Examples of NPC problems (3)

For 3SAT problem to be satisfiable, one variable from each clause should be true. Suppose there are ‘m’ clauses, then it is satisfiable if the equivalent graph has a clique of size atleast ‘m’.

If it is given that 3SAT problem is satisfiable, then we can select one variable from each clause to form a clique of size atleast ‘m’, as there will be atleast ‘m’ inter-connected nodes (one true node from each clause).

Page 20: NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA

Examples of NPC problems (4)

Maximum Independent Set Problem – It is defined as a set of vertices with no edges in between. Its equivalent decision problem is, given a graph G and some number ‘t’. Thus there exists an independent set of size >= K?

A clique problem can be reduced to maximum independent set problem. Given a problem to find a clique of size ‘K’ in a graph G is equivalent to finding a maximum independent set

in G’ (complement of G).

Page 21: NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA

Examples of NPC problems (5)

1 2

233

4

5

5

6

64

Graph G has a clique of size 4 (2,3,4,5)

Graph G’ has a maximum independent set of size 4 (2,3,4,5)