Professional Documents
Culture Documents
Decision problems
Given an input and a question regarding a problem,
determine if the answer is yes or no
Optimization problems
Find a solution with the best value
Class of P Problems
Class P consists of (decision) problems that have
polynomial time deterministic algorithm
Polynomial-time algorithms
Worst-case running time is O(nk), for some constant k
Tractable/Intractable Problems
Problems in P are also called tractable
Problems not in P are intractable or unsolvable
Can be solved in reasonable time only for small inputs
Or, can not be solved at all
- n1,000,000 is technically tractable, but really impossible nlog log log n is technically intractable, but easy
log(log(log(4294967296))) is 5
Intractable Problems
Can be classified in various categories
based on their degree of difficulty, e.g.,
NP
NP-complete
NP-hard
Class of NP Problems
TSP
2
1
1
1
5
Certificate:
hamiltonian
2
1
i = 23
3
4
2
2
1
not
hamiltonian
For each two cities, an integer cost is given to travel from one
of the two cities to the other. The salesperson wants to make a
minimum cost circuit visiting each city exactly once.
Definitions
Matching
Free Vertex
Definitions
Maximum Matching: matching with the
largest number of edges
Definition
Note that maximum matching is not
unique.
Intuition
Let the top set of vertices be men
Let the bottom set of vertices be women
Suppose each edge represents a pair of
man and woman who like each other
Graph Clique
Set of vertices
such that they
all connect
to each
other.
K-Cliques
A K-clique is a set of K nodes with all
K(K-1)/2 possible edges between them
K-Cliques
Given: (G, k)
Question: Does G contain a k-clique?
BRUTE FORCE:
Try out all {n choose k} possible locations for
the k clique
Is P = NP?
NP-Completeness (informally)
P NP
NP
Reductions
P
NP-complete
problems in NP
NP
Polynomial Reductions
Problem A
yes
Problem B
no
NP-Completeness (formally)
Implications of Reduction
(1) B NP
NP-complete
NP
yes
Problem B
no
yes
no
Problem A
- If A p B and B P, then A P
- if A p B and A P, then B P
Polynomial time
algorithm to decide B
yes
yes
no
no
transform A into B
solution
are reducible to B
Revisit Is P = NP?
NP
Hamiltonian cycle
G = (V, E) a connected, directed graph find a
cycle that visits each vertex of G exactly once
NP-complete
CFN Satisfiability
3-CNF Satisfiability
E.g.:
3-CNF is NP-Complete
clauses
Clique
Clique Verifier
Clique Problem:
Optimization problem:
Clique(G, 2) = YES
Clique(G, 3) = NO
Certificate:
A set of k nodes
Verifier:
Decision problem:
Does G have a clique of size k?
Clique(G, 3) = YES
Clique(G, 4) = NO
3-CNF p Clique
Idea:
Construct a graph G such that is satisfiable only
if G has a clique of size k
NP-naming convention
NP-complete - means problems that are
'complete' in NP, i.e. the most difficult to
solve in NP
NP-hard - stands for 'at least' as hard as NP
(but not necessarily in NP);
NP-easy - stands for 'at most' as hard as NP
(but not necessarily in NP);
NP-equivalent - means equally difficult as
NP, (but not necessarily in NP);
NP-complete
NP-hard