Professional Documents
Culture Documents
16 Complexity Theory
16 Complexity Theory
16 Complexity Theory
Types of Problems
Simple problems : Problems that can be solved in
Polynomial Time; f(n) Θ(nk), where n is input
size & k any positive integer
Example:
Job Sequencing Prim, Kruskal
Knapsack Dijkstra, Bellman Ford
Matrix Chain Floyd Warshall
BFS, DFS Network Flow
More examples:
• Satisfiability problem
• Vertex Cover
• Independence Set
• Set cover
• Clique
• Subset Sum
• Knapsack
Types of Problems
Decision Problems
Solution exist ? (Yes/No)
Search Problems
Any valid solution
Optimization Problems
Optimum solution only
NP Class:
Problems verified in Polynomial time, given a
solution to the problem
Complexity Classes
P Class:
P class problems are solved in polynomial
time, they are also verifiable in polynomial
time
NP Class:
Solution not possible in polynomial time, but
any given solution can be verified in
polynomial time
P & NP
Relationship between two classes
P ⊆ NP
Reasoning:
P & NP problems are both verifiable in polynomial
time, hence NP class contains all problems in P
class, along with problems not solvable in
polynomial time
P & NP
Relationship between two classes
P ⊆ NP
Reasoning:
P & NP problems are both verifiable in polynomial
time, hence NP class contains all problems in P
class, along with problems not solvable in
polynomial time
NP Class
P Class
P & NP
NP Class
P Class
Notation: A ≤P B
Reduction Process
Reducing Decision Problem A to B:
• A Polynomial time algorithm translates all inputs
of A to B
• If the input results in Yes output in A, it should
result in Yes output in B
• If the input results in No output in A, it should
result in No output in B
Yes Yes
Polynomial-time
reduction from A to B Algorithm to solve B
Input to A Input to No No
B
If A ≤P B and B ≤P C, then A ≤P C
(Transitive Property)
More Definitions
NP Hard
If a known NP-Hard problem, A, can be
Reduced in polynomial time to another
problem, B, then B is also NP-Hard
More Definitions
NP Hard
If a known NP-Hard problem, A, can be
Reduced in polynomial time to another
problem, B, then B is also NP-Hard
NP NP Hard
NP
Complete
Satisfiability Problem
Φ is a Boolean expression, written in Conjunctive
Normal Form (CNF) as :
Φ = (x1 ∨ x2 V x3 V x4 ) ∧ (x1 ∨ x5 V x6 V x4 ) ∧
(x5 ∨ x6 V x7) ∧ (x1 ∨ x7 V x8 V x4 V x9 ) …
x1, x2, x3, x4, … - Boolean Variables (True/False)
Satisfiability Problem
Φ is a Boolean expression, written in Conjunctive
Normal Form (CNF) as :
Φ = (x1 ∨ x2 V x3 V x4 ) ∧ (x1 ∨ x5 V x6 V x4 ) ∧
(x5 ∨ x6 V x7) ∧ (x1 ∨ x7 V x8 V x4 V x9 ) …
x1, x2, x3, x4, … - Boolean Variables (True/False)
Cook’s Theorem:
Satisfiability Problem is NP
Cook’s Theorem:
Satisfiability Problem is NP
S T
B D
S T
B D
A C
S T
B D
3-CNF expression:
Φ = (x1 V x2 V x3 ) ∧ (x1 V x2 V x3 ) ∧ (x2
V x1 V x3 ) ∧ (x1 V x2 V x3 ) ….
Number of variables : 3
Number of groups: k (as in CDP)
Graph Construction:
• Assume k = 3
• Each Boolean variable maps to a vertex in
graph
• Vertices connected via edges, except for :
– Variables in the same group(within same
clauses)
– Variables in negation, e.g., x3 not to be
connected to x3
Reducing 3-CNF to CDP
Example:
Φ = (x1 v x2 v x3 ) ∧ (x1 v x2 v x3 ) ∧ (x1 v x2 v x3 )
X1 X2 X3
X1 X1
X2 X2
X3 X3
Reducing 3-CNF to CDP
Example:
Φ = (x1 v x2 v x3 ) ∧ (x1 v x2 v x3 ) ∧ (x1 v x2 v x3 )
X1 X2 X3
X1 X1
X2 X2
X3 X3
Reducing 3-CNF to CDP
Example:
Φ = (x1 v x2 v x3 ) ∧ (x1 v x2 v x3 ) ∧ (x1 v x2 v x3 )
X1 X2 X3
X1 X1
X2 X2
X3 X3
Reducing 3-CNF to CDP
Example:
Φ = (x1 v x2 v x3 ) ∧ (x1 v x2 v x3 ) ∧ (x1 v x2 v x3 )
X1 X2 X3
X1 X1
X2 X2
X3 X3
Reducing 3-CNF to CDP
Example:
Φ = (x1 v x2 v x3 ) ∧ (x1 v x2 v x3 ) ∧ (x1 v x2 v x3 )
X1 X2 X3
X1 X1
X2 X2
X3 X3
Reducing 3-CNF to CDP
Mapping:
Φ = (x1 v x2 v x3 ) ∧ (x1 v x2 v x3 ) ∧ (x1 v x2 v x3 )
• Φ is satisfied when :
– x1 is TRUE, x2 is TRUE and x3 is TRUE
– x1 is FALSE, x2 is TRUE and x3 is FALSE
– x1 is TRUE, x2 is FALSE and x3 is TRUE
– And others
Reducing 3-CNF to CDP
Mapping:
Φ = (x1 v x2 v x3 ) ∧ (x1 v x2 v x3 ) ∧ (x1 v x2 v x3 )
• Φ is satisfied when :
– x1 is TRUE, x2 is TRUE and x3 is TRUE
– x1 is FALSE, x2 is TRUE and x3 is FALSE
– x1 is TRUE, x2 is FALSE and x3 is TRUE
– And others
• A Clique of size k exists in the graph, with
vertices matching the condition that satisfies
3-CNF expression
Reducing 3-CNF to CDP
Reduction Process:
• Conversion of 3-CNF Boolean expression to a
Graph can be completed in polynomial time
• For all inputs that satisfy the Boolean expression,
Cliques exist in the graph
• For all inputs that do not satisfy the Boolean
expression, Cliques do not exist
Reduction Process:
• Conversion of 3-CNF Boolean expression to a
Graph can be completed in polynomial time
• For all inputs that satisfy the Boolean expression,
Cliques exist in the graph
• For all inputs that do not satisfy the Boolean
expression, Cliques do not exist
3-CNF ≤P CDP
Clique Decision Problem (CDP)
Clique Decision Problem is NP-
Complete:
• A known NP-Hard problem, 3-CNF, is reduced
to CDP in polynomial time
• Any given solution for CDP can be verified in
polynomial Time
Clique Decision Problem (CDP)
Clique Decision Problem is NP-
Complete:
• A known NP-Hard problem, 3-CNF, is reduced
to CDP in polynomial time
• Any given solution for CDP can be verified in
polynomial Time
Relation: P ⊆ PSPACE
Problems solved in polynomial time can use only
polynomial space
Space Complexity
Claim: 3–CNF ∈ PSPACE
Reasoning:
Evaluate all possibilities of n variables (2n) for a
CNF using a n bit binary counter, which only
requires n bits of space
Space Complexity
Claim: 3–CNF ∈ PSPACE
Evaluate all possibilities of n variables (2n) for a
CNF using a n bit binary counter, which only
requires n bits of space
NP ⊆ PSPACE
Any problem in NP can be reduced from 3-CNF,
hence all NP problems belong to PSPACE
P, NP & PSPACE
PSPACE
NP
PSPACE Complete
PSPACE Complete
A Problem, B, is PSPACE-Complete if
– If a Problem A, belonging to PSPACE, can
be reduced to B
– B belongs to PSPACE