0% found this document useful (0 votes)
36 views23 pages

Lecture 15

This document discusses NP-completeness and techniques for proving that problems are NP-complete. It introduces the concepts of P, NP, and NP-complete problem classes. Key points covered include: reductions can be used to show that a problem is as hard as other NP-complete problems; the first NP-complete problem identified was circuit satisfiability; proving problems are NP-complete indicates they are very likely intractable but does not definitively prove hardness.

Uploaded by

f20201862
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views23 pages

Lecture 15

This document discusses NP-completeness and techniques for proving that problems are NP-complete. It introduces the concepts of P, NP, and NP-complete problem classes. Key points covered include: reductions can be used to show that a problem is as hard as other NP-complete problems; the first NP-complete problem identified was circuit satisfiability; proving problems are NP-complete indicates they are very likely intractable but does not definitively prove hardness.

Uploaded by

f20201862
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

BITS, PILANI – K. K.

BIRLA GOA CAMPUS

Design & Analysis of Algorithms


(CS F364)

Lecture No. 15

1
NP Completeness
Until now we have been designing algorithms for
specific problems.
We have seen running times O(logn), O(n), O(nlogn), O(n2),
O(n3), .
We often think about problems we can solve in polynomial
time O(nk) as being easy/practically solvable/tractable
We have seen a lot of these
Similarly we think about problems we need exponential
time like O(2n) to solve as being hard/practically
unsolvable/intractable
We have seen a few of these.
NP Completeness
Showing that a problem has an efficient
algorithm is relatively easy.
“All’ that is needed is to demonstrate an
algorithm.
Proving that no efficient algorithm exists for a
particular problem is difficult.
How can we prove the non-existence of
something?
NP Completeness
Goal:
To study interesting class of problems (called NP
Complete)
whose status is unknown.
i.e., no polynomial time algorithm has yet been
discovered, nor has anyone yet been able to prove that
no polynomial time algorithm can exist for any one of
them.
One of the deepest research problem in theoretical
computer science.
NP Complete
• The problem of finding an efficient solution to an NP-
Complete problem is known as P ≠ NP?.
• There is currently a US$1,000,000 award offered by the
Clay Institute (http://www.claymath.org/) for its
solution
• In the remainder of this module we will introduce the
notation, terminology and tools needed to discuss NP-
Complete problems and to prove that problems are
NP-complete.
Proving that a problem is NP-Complete does not prove
that the problem is hard.
It does indicate that the problem is very likely to be hard.
NP Complete
Why so difficult?
Several NP-Complete Problems are very similar to problems
that we know already how to solve in polynomial time.
For example:
• Shortest simple path vs. Longest simple path
• Fractional Knapsack vs. 0-1 Knapsack
• Euler Tour vs Hamiltonian Cycle
• 2-CNF Satisfiability vs. 3-CNF Satisfiability
In Boolean logic, a formula is in conjunctive normal
form (CNF) if it is a conjunction of one or more
clauses, where a clause is a disjunction of literals;
otherwise put, it is a product of sums or an AND of
ORs
Class P
Informal discussion
The class P consists of those problems that are solvable
in polynomial time.
More specifically, they are problems that can be solved
in time O(nk) for some constant k, where n is the size of
the input to the problem.
Most of the problems we have examined are in class P
Class NP
Consider Hamiltonian cycle problem
Given a directed graph G = (V, E) a ‘certificate’ is a
sequence v = (v1 ,v2 ,v3 ,…..v|V|) of |V| vertices.
We can easily check/verify in polynomial time if v is an
Hamiltonian cycle or not.
Consider the problem of 3-CNF Satisfiability
A certificate here is an assignment of values to the
variables.
We can easily check/verify in polynomial time
whether the assignment satisfies the boolean formula.
Class NP
The class NP consists of those problems that are
verifiable in polynomial time.
Already observed that Hamiltonian Cycle Problem &
3-CNF Satisfiability problem are in class NP.
Note
If a problem is in P then we can solve it in polynomial
time & so given a certificate it is verifiable in
polynomial time
Therefore P  NP
The open question is whether P ⊂ NP?
Class NP-Complete
A problem is in the class NPC (referred as NP-Complete) if
1. It is in NP
2. Is as ‘hard’ as any problem in NP
Note
Most computer scientists believe that NP-complete
problems are intractable.
Because, if any NP-complete problem can be solved in
polynomial time then every problem in NP has a
polynomial time algorithm.
- We will prove this later
NPC
Technique to show that the problem is NP-complete:
Different than what we have been doing:
We are not trying to prove the existence of polynomial
time algorithm
Instead we are trying to show that no efficient or
polynomial time algorithm is likely to exist.
Three key ideas needed to show problem is NPC
1. Decision problem vs. Optimization problem
2. Reductions
3. First NP-complete problem
Decision problem vs. Optimization problem
Decision problem vs. Optimization problem
Many problems of interest are Optimization problems

An Decision problem asks us to check if something is


true (possible answers: ‘yes’ or ‘no’)
Example:
–PRIMES
•Instance: A positive integer n
•Question: Is n prime?
Optimization problem
An optimization problem asks us to find, among all
feasible solutions, one that maximizes or minimizes a
given objective
Example: –
Single shortest-path problem (SPP)
•Instance: Given a directed, weighted graph G & two
nodes s and t of G
•Problem: find a simple path from s to t of minimum
total length
–Possible answer: ‘a shortest path from s to t ’
Decision problem vs. Optimization problem

Remark: An optimization problem usually has a


corresponding decision problem.
Usually easily defined with the help of a bound on the
value of feasible solutions
Examples:
MST vs. Decision Spanning Tree(DST)
SPP vs. Decision SPP (DKnapsack)
Decision problem vs. Optimization problem

Optimization problem: Minimum Spanning Tree


Given a weighted graph find a minimum spanning tree
(MST) of G

Decision problem: Decision Spanning Tree (DST)


Given a weighted graph and an integer k, does G have a
spanning tree of weight at most k?
Decision problem vs. Optimization problem
Optimization SPP
Instance: Given a weighted graph G, two nodes s and t of
G
Problem: find a simple path from s to t of minimum total
length

Decision SPP
Instance: A weighted graph G, two nodes s and t of G,
and a bound b
Question: is there a simple path from s to t of length at
most b?
Decision problem vs. Optimization problem
Observe, if one can solve an optimization problem (in
polynomial time), then one can answer the decision
version (in polynomial time)
Example: If we know how to solve MST we can solve DST
which asks if there is an Spanning Tree with weight at
most k.
How?
First solve the MST problem and then check if the MST
has cost k.
If it does, answer Yes.
If it doesn’t, answer No
Decision problem vs. Optimization problem

Observe, if optimization problem is easy then the


decision version is easy.
Alternately
If we give evidence that a decision problem is hard then
we give evidence that its corresponding optimization
problem is hard.
This is important observation for us.
Reduction
Let us consider a decision problem A
We want to solve it in polynomial time
Suppose we already know how to solve another decision
problem B in polynomial time
Additionally we also have a procedure/algorithm that
transforms any instance x of A into some instance y of B
with the following properties:
• The transformation takes polynomial time
• Answer for x is YES if and only if the answer for y is also
YES
Such a procedure is called a polynomial time reduction
algorithm .
It helps us to solve problem A in polynomial time.
Reduction
Pictorial Representation
yes
yes
Instance x Polynomial time Instance y Polynomial time
of A reduction algorithm of B algorithm to decide B no no

Polynomial time algorithm to decide A

1. Given an instance x of A, use polynomial time reduction


algorithm to transform it to an instance y of problem B
2. Run the polynomial time decision algorithm for B on the
instance y
3. Use the answer for y as the answer for x
Reduction
Using reduction idea to prove a decision problem is
hard.
Suppose we have to prove that no polynomial time
algorithm can exist for a decision problem B.
Suppose we have a decision problem A for which we
already know that no polynomial time algorithm can
exist.
Suppose further we have a polynomial time reduction
algorithm transforming instances of A to instances of B.
By contradiction we can prove that no polynomial time
algorithm can exist for B.
Reduction
Suppose otherwise, i.e., suppose that B has a
polynomial time algorithm .
Then as observed earlier, we would have a polynomial
time algorithm for A, which is a contradiction.
1st NP-Complete Problem
Key step in using reduction is to start with a already
known NP-Complete problem.
We need a ‘first’ NP-Complete problem.
The problem we shall use is the Circuit-Satifiability.

You might also like