NP-Complete Problems: Dr. C.V. Suresh Babu
NP-Complete Problems: Dr. C.V. Suresh Babu
NP-Complete Problems: Dr. C.V. Suresh Babu
Problems
Dr. C.V. Suresh Babu
Problems that
• What if aCross
problem s the Line
has:
o An exponential upper bound
A polynomial lower bound
o
problem is intractable
• b P r r o b l e m
Theolower
u nbound
d susuggests
g g ests
the problem is tractable
• The lower bound is linear:
s
the
O(N)
• They are all reducible to
each other
o If we find a reasonable
algorithm (or prove
intractability) for one, then we
Traveling Salesman
5-
Clique
Hamiltonian Path
Map Coloring
Vertex Cover (VC)
• Given a graph and an integer k, is there a
collection of k vertices such that each edge
is connected to one of the vertices in the
collection?
• With N
Class
restrictions M classes to be
S c h Pro
tscheduled, dblem
e obl ulin
ea c he rs w tih c e rt ai
can
we:
o Schedule all the classes
g g
onMake
hour sure that no two teachers
teach the same class at the same
time
o No teacher is scheduled to teach
two classes at once
Pair Programming Problem
• With N students and K projects, where N
is even, can we:
o Assign pairs of students to each
project
o Every student works on every project
o No student has the same partner
more than once
• Is this an NP-complete
problem?
Graph isomorphism
• Graph isomorphism is NP-hard; is it NP-
complete?
NP and P
• What is NP?
• NP is the set of all decision problems (question with yes-
or-no answer) for which the 'yes'-answers can be
verified in polynomial time (O(n^k) where n is the
problem size, and k is a constant) by a deterministic
Turing machine.
Polynomial time is sometimes used as the definition
• of fast or quickly.
• What is P?
P is the set of all decision problems which can be
solved
in polynomial time by a deterministic Turing machine.
Since it can solve in polynomial time, it can also be
verified in polynomial time. Therefore P is a subset of
NP.
NP-Complete
• What is NP-Complete?
• A problem x that is in NP is also in NP-Complete if
and only if every other problem in NP can be
quickly (ie. in polynomial time) transformed into x.
In other words:
• x is in NP, and
• Every problem in NP is reducible to x
• So what makes NP-Complete so interesting is that
if any one of the NP-Complete problems was to
be solved quickly then all NP problems can be
solved quickly
NP-Hard
• What is NP-Hard?
• NP-Hard are problems that are at least as hard as
the hardest problems in NP. Note that NP-
Complete problems are also NP-hard. However
not all NP-hard problems are NP (or even a
decision problem), despite having 'NP' as a prefix.
That is the NP in NP- hard does not mean 'non-
deterministic polynomial time'. Yes this is confusing
but its usage is entrenched and unlikely to
change.
Certif
i
• Returning true: in order to show that
the schedule can cates
be made, we only
have to show one schedule that
works
o This is called a certificate.
Nondeterminism
• Nondeterministic algorithms produce
an answer by a series of “correct
guesses”