NP Complete
NP Complete
NP Completeness
Biswajit Sahoo,
KIIT
Course
Contents
2
Intractabe Problem
Nondeterministic Algorithm
P and NP Defination
Optimization & Decision Problem
Verification of Problem
Reducibility
NP Complete & NP Hard Defination
Cook’s Theorem
Examples of NP Complete
Clique Decision Problem
Hamiltonian Cycle, TSP
Sum of Subset, Graph Coloring
Biswajit Sahoo, KIIT
Tractability
4
if(key==a[i]) //1
return(i); //1
else
return(-1); //1
} Total Running time=O(1)
NP
n
Biswajit Sahoo, KIIT
Optimization and Decision Problems
11
3 4
5 8
1, 5, 3, 4, 8, 6, 9, 2, 7, 1 6
Source 1 Verified in P
9
7
2
Biswajit Sahoo, KIIT
Reducibility
15
Yes for A
Yes
α Poplynomial β
Algorithm for B
Reduction No
No for A
Decision Algorithm for A
NP-Complete NP-Hard
Formula SAT
TSP
1 2 1 2
Clique of size 2
4 3 4 3
1 2 2
4 3 4 3
Clique of size 3
4 3
5
4 2
6 5
4 2
3 Clique of size 4
6 5
CDC NP 1
4 2
6 5
X1 x2 X3
x3 X1
X2 X2
x1 x3
V = { <a, i> | a ∈ Ci }
Biswajit Sahoo, KIIT E= ( <a, i><b, j>) | b ≠ , i ≠ j
φ = (V x2 V ) Λ (x1 V V x3) Λ (x1 V x2 V )
C1C2 C3
X1 x2 X3
x3 X1
X2 X2
x1 x3
V = { <a, i> | a ∈ Ci }
Biswajit Sahoo, KIIT E= ( <a, i><b, j>) | b ≠ , i ≠ j
φ = (V x2 V ) Λ (x1 V V x3) Λ (x1 V x2 V )
C1C2 C3
X1 x2 X3
x3 X1
X2 X2
x1 x3
V = { <a, i> | a ∈ Ci }
Biswajit Sahoo, KIIT E= ( <a, i><b, j>) | b ≠ , i ≠ j
φ = (V x2 V ) Λ (x1 V V x3) Λ (x1 V x2 V )
C1C2 C3
X1 x2 X3
x3 X1
X2 X2
x1 x3
V = { <a, i> | a ∈ Ci }
Biswajit Sahoo, KIIT E= ( <a, i><b, j>) | b ≠ , i ≠ j
φ = (V x2 V ) Λ (x1 V V x3) Λ (x1 V x2 V )
C1C2 C3
X1 x2 X3
x3 X1
X2 X2
x1 x3
V = { <a, i> | a ∈ Ci }
Biswajit Sahoo, KIIT E= ( <a, i><b, j>) | b ≠ , i ≠ j
φ = (V x2 V ) Λ (x1 V V x3) Λ (x1 V x2 V )
C1C2 C3
Assignment:
X1 x2 X3
x1=0, x2=1, x3=1
x3 X1
X2 X2
x1 x3
Assignment:
X1 x2 X3
x1=0, x2=1, x3=1
TRUE
x3 X1
X2 X2
x1 x3
X2 X2
x1 x3
X2 X2
x1 x3
X2 X2
x1 x3
X2 X2
x1 x3
X2 X2
x1 x3
X2 X2
x1 x3
TSP is in NP-Complete ?
i. TSP NP
ii. Hamiltonian Cycle p TSP
TSP NP
3 4
5 8
1, 5, 3, 4, 8, 6, 9, 2, 7, 1 6
Source 1 Verified in P
9
7
2
Biswajit Sahoo, KIIT
Reducing to Travelling Salesperson Problem (TSP)
48
1, 5, 3, 4, 8, 6, 9, 2, 7, 1 6
Source 1
9
7
2
All edges are present, Hamiltonian cycle exists
Biswajit Sahoo, KIIT TSP exists with cost k
TSP of cost k?
50 Hamiltonian Cycle?
1, 5, 3, 4, 8, 6, 9, 2, 7, 1 6
Source 1
9
7
2
No Hamiltonian cycle exists
Biswajit Sahoo, KIIT No TSP exist with cost k
51