NP-HARD ANDNP-COMPLETE PROBLEMS
-
Upload
rijas-rasheed -
Category
Documents
-
view
220 -
download
0
Transcript of NP-HARD ANDNP-COMPLETE PROBLEMS
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 1/26
NP -HARD AND
NP -COMPLETE
PROBLEMS
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 2/26
Basic concepts
• We are concerned with distinction
between the problems that can be solved
by polynomial time algorithm and
problems for which no polynomial time
algorithm is known.
• Example for the first group is ordered
searching its time complexity is O (log n)time complexity of sorting is O (n log n).
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 3/26
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 4/26
• Here we do is show that many of the
problems for which there are no
polynomial time algorithms are
computationally related
• These are given the names NP hard and
NP complete
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 5/26
• A problem that is NP complete has the
property that it can be solved in polynomial
time iff all other NP complete problem can
be solved in polynomial time
• If an NP hard problem can be solved in
polynomial time ,then all NP complete
problem can be solved in polynomial time.
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 6/26
• All NP-complete problems are NP-hard.
but some NP-hard problems are not
known to be NP-complete
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 7/26
NON DETERMINISTIC
ALGORITHMS
• Algorithms with following property are
termed deterministic algorithm.
The result of every operation is uniquely
determined.
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 8/26
• We can allow algorithms to contain
operations whose outcomes are not
uniquely defined but are limited to
specified set of possibilites
• The machine executing such type of
operations is allowed to choose any of
these outcomes subjected to a terminationcondition to be defined later
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 9/26
• To specify such algorithms, we define
three new function
• Choice(s)
• Failure()
• Success()
• X:=choice(1,n)could result in x beingassigned any one of the integers in
range[1,n]
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 10/26
• A nondeterministic algorithm terminating
unsuccessfully if and only if there exist no
set of choice leading to successful signals
•
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 11/26
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 12/26
The classes NP- hard and NP-
complete
• An algorithm A is of polynomial complexity if
there exist a polynomial P() such that the
computing time of A is O(p(n)) for any input
size.
• P is the set of all decision problems solvable
by deterministic algorithms in polynomial
time
• NP is the set of all decision problems
solvable by nondeterministic algorithms in
polynomial time.
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 13/26
• Since deterministic algorithms are just a
special case of nondeterministic ones, we
conclude that P NP.
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 14/26
• Definition: - Let L1 and L2 be two problems.Problem L1 reduces to L2 if and only if there is a way to solve L1 by a
deterministic polynomial time algorithmusing a deterministic polynomial timealgorithm that solves L2 in polynomial time
• ie, If we have a polynomial time algorithmfor L2 ,then we can solve L1in polynomialtime
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 15/26
• A Problem L is NP-hard if and only if it’s
satisfiability reduces to L
• A Problem L is NP-complete if and only if
L is NP-hard and L NP
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 16/26
NPP
ommon e e re a ons p
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 17/26
ommon y e ve re a ons pamong P,NP,NP-complete and NP-
hard
P
NP
NP-hard
NP complete
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 18/26
• As an example of an NP hard decision
problem which is not NP completeconsider the example of halting problemfor
a deterministic algorithms
• The halting problem is to determine anarbitrary deterministic algorithm A and
input I whether algorithm A with input I
ever terminates(or enters an infinite loop)
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 19/26
• It is well known that this problem isundecidable .Hence there exist no
algorithm to solve the problem.so it cannot
be in NP
• To show satifiability reduces to ( )the
halting problem
simply construct an algorithm A whose input is a prepositional
formulaeX.If X has n varables,then A tries
out all 2n possible truth assignments and
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 20/26
Verifies whether X is satisfiable.If it is then
A stops,If it is not ,then A enters in an
infinite loop. Hence A halts on input X iff X
is satisfiable.If we had a polynomial time Algorithm for the halting problem ,then we
could solve satisfiability problem in
polynomial time using A and X as input toalgorithm for the halting problem
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 21/26
• Hence the halting problem is an NP hard
decision problem which is not NP
complete
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 22/26
COOK’S THEOREM
Cook’s theorem states that satisfiability in P
if and only if P= NP
Proof:- We have already seen satisfiability
in NP
Given P=NP
Then satisfiability in pIt remains to show that if satisfiability in P
P=NP
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 23/26
• To do this, we show how to obtain from
any polyomial time nondeterministic
decision Algorithm A and input I a
formula Q(A,I)such that Q is satisfiable iff A has a successful termination with input I
• If the length of I is n then then the time
complexity of A is p(n) for somepolynomial p(),then the length of Q is
O(p3(n) logn)= O(p4 (n))
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 24/26
• The time needed to construct Q is also
O(p3(n) logn)
• A deterministic Algorithm Z to determine
outcome of A on any input I can be easily
obtained
• Algorithm Z simply computes Q and then
uses a detrministic Algorithm for
satisfiability problem to determine whether
Q is satisfiable
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 25/26
• If O(q(m)) is the time needed to determine
whether formula of length m is satisfiablethen the compexity of Z is O(p3(n) logn)+
q(p3 (n) logn)
• If satisfiability is in P then q(m) is apolynomial function of m and compexity of
Z becomes O(r(n)) for some polynomial r()
• Hence if satisfiability is in P ,then for every
nondeterministic algorithm A in NP we can
obtain a deterministic Z in P
7/30/2019 NP-HARD AND�NP-COMPLETE �PROBLEMS
http://slidepdf.com/reader/full/np-hard-andnp-complete-problems 26/26
• So It shows that if satisfiability is in P ,then
P=NP