Documentos de Académico
Documentos de Profesional
Documentos de Cultura
P Problem
In computational complexity theory, P is the complexity class containing decision
problems which can be solved by a deterministic Turing machine using a polynomial
amount of computation time, or polynomial time.
P is known to contain many natural problems, including linear programming, calculating
the greatest common divisor, and finding a maximum matching.
P is often taken to be the class of computational problems which are "efficiently
solvable" or "tractable", although there are potentially larger classes that are also
considered tractable such as RP and BPP. Also, there exist problems in P which are
intractable in practical terms; for example, some require at least n1000000 operations.
Relationships to other classes
A generalization of P is NP, which is the class of languages decidable in polynomial time
on a non-deterministic Turing machine. We then trivially have P is a subset of NP. One
of the largest open problems currently in theoretical computer science is whether P = NP/
P is also known to be at least as large as L, the class of problems decidable in a
logarithmic amount of memory space. A decider using O(log n) space cannot use more
than 2O(log n)=nO(1) time, because this is the total number of possible configurations; thus, L
is a subset of P. Another important problem is whether L = P. We do know that P =
ALOGSPACE, the set of problems solvable in logarithmic memory by alternating Turing
machines. P is also known to be no larger than PSPACE, the class of problems decidable
in polynomial space. Again, whether P = PSPACE is an open problem. To summarize:
Here, EXPTIME is the class of problems solvable in exponential time. Of all the classes
shown above, only two strict containments are known:
NP Problem
In computational complexity theory, NP ("Non-deterministic Polynomial time") is the set
of decision problems solvable in polynomial time on a non-deterministic Turing machine.
Equivalently, it is the set of problems that can be "verified" by a deterministic Turing
machine in polynomial time; more detail below.
If n is composite, then this function will return true for some input d. If n is prime,
however, this function will always return false, regardless of d. All problems in NP have
a deterministic function just like this, which accepts only when given both an input and
proof that the input is in the language. We must be able to check if the proof is correct in
polynomial time. We call such a machine a verifier for the problem.
If we have a nondeterministic machine, testing a number for compositeness is easy. It can
branch into n different paths in just O(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 NP problems is to efficiently find the answer, given an efficient
(polynomial-time) way of verifying it once it is found. This challenge was solved (see
AKS Primality Test) for compositeness testing only in 2002; there is still no known
polynomial-time way to solve the more general factoring problem of determining
whether a number between 1 and m divides n.
Additional examples include:
The graph isomorphism problem of determining whether two graphs can be
drawn identically
The traveling salesman problem, where we want to know if there is a route of
some length that goes through all the nodes in a certain network
The boolean satisfiability problem, where we want to know if a certain formula in
propositional logic with boolean variables is satisfiable or not
At each city it visits it "guesses" the next city to visit, until it has visited every
vertex. If it gets stuck, it stops immediately.
At the end it verifies that the route it has taken has cost less than k in O(n) time.
One can think of each guess as "forking" a new copy of the Turing machine to follow
each of the possible paths forward, and if at least one machine finds a route of distance
less than k, that machine accepts the input.
What makes this a natural decision version of the problem is that, if we could solve this
problem quickly, we could use binary search to solve the original computation problem
(finding the route and its exact length) quickly as well.
NP-hard Problem
In computational complexity theory, NP-hard (Non-deterministic Polynomial-time hard)
refers to the class of decision problems that contains all problems H, such that for every
decision problem L in NP there exists a polynomial-time many-one reduction to H,
written
. Informally, this class can be described as containing the decision
problems that are at least as hard as any problem in NP. This intuition is supported by the
fact that if we can find an algorithm A that solves one of these problems H in polynomial
time, we can construct a polynomial time algorithm for any problem L in NP by first
performing the reduction from L to H and then running the algorithm A.
So, formally, a language L is NP-hard if L' in NP,
L is in NP, then L is called NP-complete.
The notion of NP-hardness plays an important role in the discussion about the
relationship between the complexity classes P and NP. The class NP-hard can be
understood as the class of problems that are NP-complete or harder.
A common mistake is to think that the "NP" in "NP-hard" stands for "non-polynomial".
Although it is widely suspected that there are no polynomial-time algorithms for these
problems, this has never been proved. Furthermore, it must also be taken into
consideration, that polynomial complexity problems are a subset of NP complexity
problems and therefore contained in the NP-hard complexity class.
Examples
An example of an NP-hard problem is the decision problem SUBSET-SUM which is this:
given a set of integers, does any non empty subset of them add up to zero? That is a
yes/no question, and happens to be NP-complete.
There are also decision problems that are NP-hard but not NP-complete, for example the
halting problem. This is the problem "given a program and its input, will it run forever?"
That's a yes/no question, so this is a decision problem. It is easy to prove that the halting
problem is NP-hard but not NP-complete. For example the Boolean satisfiability problem
can be reduced to the halting problem by transforming it to the description of a Turing
machine that tries all truth value assignments and when it finds one that satisfies the
formula it halts and otherwise it goes into an infinite loop. It is also easy to see that the
halting problem is not in NP since all problems in NP are decidable and the halting
problem is not.
Alternative definitions
An alternative definition of NP-hard that is often used replaces polynomial-time manyone reductions with polynomial-time Turing reductions. This notion of NP-hardness can
be formulated for function problems and not just decision problems.
In this sense, the problem H is NP-hard if and only if every decision problem L in NP can
be solved in polynomial time by an oracle machine with an oracle for H. (Informally we
can think of such a machine as an algorithm that can call a subroutine for solving H and
solves L in polynomial time if the subroutine call takes only one step to compute.) If we
find a polynomial-time algorithm for an NP-hard problem then we have a polynomialtime algorithm for all problems in NP-easy and indeed for all problems in NP.
Whether this definition of NP-hardness is equivalent 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 NP-completeness.
NP-Complete Problem
In complexity theory, the NP-complete problems are the most difficult problems in NP
("non-deterministic polynomial time") in the sense that they are the ones most likely not
to be in P. The reason is that if you could find a way to solve any NP-complete problem
quickly (in polynomial time), then you could use that algorithm to solve all NP problems
quickly. The complexity class consisting of all NP-complete problems is sometimes
referred to as NP-C. A more formal definition is given below.
One example of an NP-complete problem is the subset sum problem which is: given a
finite set of integers, determine whether any non-empty subset of them sums to zero. A
supposed answer is very easy to verify for correctness, but no one knows a significantly
faster way to solve the problem than to try every single possible subset, which is very
slow.
Formal definition of NP-completeness
A decision problem C is NP-complete if it is complete for NP, meaning that:
1. it is in NP and
2. it is NP-hard, i.e. every other problem in NP is reducible to it.
"Reducible" here means that for every problem L, there is a polynomial-time many-one
reduction, a deterministic algorithm which transforms instances l L into instances c
C, such that the answer to c is YES if and only if the answer to l is YES. To prove that a
NP problem A is in fact a NP-complete problem it is sufficient to show that an already
known NP-complete problem reduces to A.
A consequence of this definition is that if we had a polynomial time algorithm for C, we
could solve all problems in NP in polynomial time.
Nobody has yet been able to prove whether NP-complete problems are in fact solvable in
polynomial time, making this one of the great unsolved problems of mathematics.
A problem satisfying condition 2 but not necessarily condition 1 is said to be NP-hard.
Informally, an NP-hard problem is "at least as hard as" any NP-complete problem, and
perhaps harder. For example, choosing the perfect move in certain board games on an
arbitrarily large board is NP-hard or even strictly harder than the NP-complete
problems.
Example problems
An interesting example is the graph isomorphism problem, the graph theory problem of
determining whether a graph isomorphism exists between two graphs. Two graphs are
isomorphic if one can be transformed into the other simply by renaming vertices.
Consider these two problems:
Imperfect solutions
At present, all known algorithms for NP-complete problems require time that is
superpolynomial in the input size. It is unknown whether there are any faster algorithms.
Therefore, to solve an NP-complete problem for any nontrivial problem size, generally
one of the following approaches is used:
Heuristic: An algorithm that works "reasonably well" on many cases, but for
which there is no proof that it is both always fast and always produces a good
result.