np complete probelm
TRANSCRIPT
-
7/21/2019 NP Complete Probelm
1/7
Charotor Institute of Technology-Changa Prepared by Trupti M. Kodinariya
P Problem
In computational complexity theory, P is the complexity class containing decision
problems which can be soled by a deterministic Turing machine using a polynomialamount of computation time, or polynomial time.
Pis !nown to contain many natural problems, including linear programming, calculating
the greatest common diisor, and finding a maximum matching.
P is often ta!en to be the class of computational problems which are "efficientlysolable" or "tractable", although there are potentially larger classes that are also
considered tractable such as RP and BPP. #lso, there exist problems in Pwhich are
intractable in practical terms$ for example, some re%uire at least n&''''''operations.
Relationships to other classes
# generali(ation of Pis NP, which is the class of languages decidable in polynomial timeon a non-deterministic Turing machine. )e then triially hae P is a subset of NP. *ne
of the largest open problems currently in theoretical computer science is whether P+ NP
P is also !nown to be at least as large as L, the class of problems decidable in alogarithmic amount of memory space. # decider using *log n space cannot use more
than /*log n+n*&time, because this is the total number of possible configurations$ thus, Lis a subset of P. #nother important problem is whether L + P. )e do !now that P +
#0*12P#C3, the set of problems solable in logarithmic memory by alternating Turingmachines. Pis also !nown to be no larger than PSPACE, the class of problems decidable
in polynomial space. #gain, whether P+ PSPACEis an open problem. To summari(e4
5ere, EXPTIMEis the class of problems solable in exponential time. *f all the classes
shown aboe, only two strict containments are !nown4
P is strictly contained in EXPTIME. Conse%uently, all EXPTIME-hard
problems lie outside P, and at least one of the containments to the right of Paboe is strict in fact, it is widely belieed that all three are strict.
Lis strictly contained in PSPACE.
NP Problem
In computational complexity theory, NP"6on-deterministic Polynomial time" is the set
of decision problems solable in polynomial time on a non-deterministic Turing machine.
3%uialently, it is the set of problems that can be "erified" by a deterministic Turingmachine in polynomial time$ more detail below.
&
-
7/21/2019 NP Complete Probelm
2/7
Charotor Institute of Technology-Changa Prepared by Trupti M. Kodinariya
Introduction and applications
The importance of this class of decision problems is that it contains many interesting
searching and optimi(ation problems where we want to !now if there exists a certainsolution for a certain problem.
#s a simple example, consider the problem of determining whether a number n is a
composite number. 7or large numbers, this seems li!e a ery difficult problem to sole
efficiently$ the simplest approaches re%uire time which is exponential in log n, thenumber of input bits. *n the other hand, once we8e found a candidate factor of n, the
following function can %uic!ly tell us whether it really is a factor4
booleanisNontrivialFactor(n, d)
ifnis divisible by dand
d 1 andd n
return true
else
return false
If n is composite, then this function will return true for some input d. If n is prime,
howeer, this function will always return false, regardless of d. #ll problems in NPhaea deterministic function 9ust li!e this, which accepts only when gien both an input and
proof that the input is in the language. )e must be able to chec! if the proof is correct in
polynomial time. )e call such a machine a verifierfor the problem.
If we hae a nondeterministic machine, testing a number for compositeness is easy. It canbranch into n different paths in 9ust *log n steps$ then, each of these can call
isNontrivialFactor(n, d) for one d. If any succeed, the number is composite$
otherwise, it is prime.
Thus, the challenge of NPproblems is to efficiently find the answer, gien an efficientpolynomial-time way of erifying it once it is found. This challenge was soled see
#K2 Primality Test for compositeness testing only in /''/$ there is still no !nown
polynomial-time way to sole the more general factoring problem of determiningwhether a number between & and mdiides n.
#dditional examples include4
The graph isomorphism problem of determining whether two graphs can be
drawn identically
The traeling salesman problem, where we want to !now if there is a route ofsome length that goes through all the nodes in a certain networ!
The boolean satisfiability problem, where we want to !now if a certain formula in
propositional logic with boolean ariables is satisfiable or not
/
-
7/21/2019 NP Complete Probelm
3/7
-
7/21/2019 NP Complete Probelm
4/7
Charotor Institute of Technology-Changa Prepared by Trupti M. Kodinariya
time, we can construct a polynomial time algorithm for any problem L in NPby first
performing the reduction from Lto Hand then running the algorithm A.
2o, formally, a language Lis 6P-hard if 08 in NP, . If it is also the case thatLis in NP, then Lis called 6P-complete.
The notion of NP-hardness plays an important role in the discussion about the
relationship between the complexity classes P and 6P. The class NP#hard can be
understood as the class of problems that are 6P-complete or harder.
# common mista!e is to thin! that the "6P" in "6P-hard" stands for "non-polynomial".#lthough it is widely suspected that there are no polynomial-time algorithms for these
problems, this has neer been proed. 7urthermore, it must also be ta!en into
consideration, that polynomial complexity problems are a subset of 6P complexityproblems and therefore contained in the 6P-hard complexity class.
E"amples
#n example of an 6P-hard problem is the decision problem 2
-
7/21/2019 NP Complete Probelm
5/7
Charotor Institute of Technology-Changa Prepared by Trupti M. Kodinariya
)hether this definition of 6P-hardness is e%uialent to the one at the beginning of this
article for the case of decision problems is still an open problem and is discussed in
more detail in the article on 6P-completeness.
NP#Complete Problem
In complexity theory, the NP#completeproblems are the most difficult problems in NP"non-deterministic polynomial time" in the sense that they are the ones most li!ely not
to be in P. The reason is that if you could find a way to sole any6P-complete problem%uic!ly in polynomial time, then you could use that algorithm to sole allNPproblems
%uic!ly. The complexity class consisting of all 6P-complete problems is sometimes
referred to as NP#C. # more formal definition is gien below.
*ne example of an NP#completeproblem is the subset sum problem which is4 gien a
finite set of integers, determine whether any non-empty subset of them sums to (ero. #
supposed answer is ery easy to erify for correctness, but no one !nows a significantly
faster way to sole the problem than to try eery single possible subset, which is eryslow.
%ormal de$inition o$ NP#completeness
# decision problem Cis NP#completeif it is complete for NP, meaning that4
&. it is in NPand
/. it is 6P-hard, i.e. eery other problem in NPis reducible to it.
"?educible" here means that for eery problem L, there is a polynomial-time many-one
reduction, a deterministic algorithm which transforms instances l Linto instances cC, such that the answer to cis @32 if and only if the answer to lis @32. To proe that a
NPproblem Ais in fact a NP#completeproblem it is sufficient to show that an already!nown NP#completeproblem reduces to A.
# conse%uence of this definition is that if we had a polynomial time algorithm for C, we
could sole all problems in NPin polynomial time.
6obody has yet been able to proe whether NP#completeproblems are in fact solable inpolynomial time, ma!ing this one of the great unsoled problems of mathematics.
# problem satisfying condition / but not necessarily condition & is said to be NP#hard.Informally, an NP#hardproblem is "at least as hard as" any NP#complete problem, and
perhaps harder. 7or example, choosing the perfect moe in certain board games on anarbitrarily large board is NP#hard or een strictly harder than the NP#completeproblems.
A
-
7/21/2019 NP Complete Probelm
6/7
-
7/21/2019 NP Complete Probelm
7/7
Charotor Institute of Technology-Changa Prepared by Trupti M. Kodinariya
&euristic4 #n algorithm that wor!s "reasonably well" on many cases, but for
which there is no proof that it is both always fast and always produces a good
result.
With respect to other reductions
In the definition of NP#completegien aboe, the term "reduction" was used in the
technical meaning of a polynomial-time many-one reduction.
#nother type of reduction is polynomial-time Turing reduction. # problem X is
polynomial-time Turing-reducible to a problem Yif, gien a subroutine that soles Y inpolynomial time, you could write a program that calls this subroutine and soles X in
polynomial time. This contrasts with many-one reducibility, which has the restriction that
the program can only call the subroutine once, and the return alue of the subroutine mustbe the return alue of the program.
#nother type of reduction that is also often used to define NP#completeness is thelogarithmic-space many-one reduction which is a many-one reduction that can be
computed with only a logarithmic amount of space. 2ince eery computation that can bedone in logarithmic space can also be done in polynomial time it follows that if there is a
logarithmic-space many-one reduction then there is also a polynomial-time many-one
reduction. This type of reduction is more refined than the more usual polynomial-timemany-one reductions and it allows us to distinguish more classes such as P#complete.
)hether under these types of reductions the definition of NP#completechanges is still an
open problem.
E