12 A. M. C. A. Koster, X. Mu
˜
noz
usually say that it will pick the first path to lead to a successful or “yes” result. The
idea of non-determinism in effective computing systems can be explained without
entering into details of non-deterministic computing machines (the reader is referred
to [8, 50] for a more detailed explanation). A decision problem whose “yes” solution
can be computed in polynomial time on a non-deterministic machine is equivalent
to a problem where a proposed “yes” solution can be verified as correct in polyno-
mial time on a deterministic machine. You can specify a non-deterministic machine
that guesses one solution, following all of those paths at once, and returning a result
whenever it finds a solution that it can verify is correct. So, if you can check a so-
lution deterministically in polynomial time (not produce a solution, but just verify
that the solution is correct), then the problem is in NP.
The distinction can become much clearer with an example. A classic problem
is the subset sum problem. In the subset sum problem, an arbitrary set of integers
is given. The question is whether there exists a nonempty subset of values in the
set whose sum is 0? It should be pretty obvious that checking a solution is in P:a
solution is a list of integers whose maximum length is the size of the entire set; to
check a potential solution, add the values in the solution, and see if the result is 0.
The computational effort of this procedure is O(n) where n is the number of values
in the set. But finding a solution is hard. The solution could be any subset of any size
larger than 0; for a set of n elements, there are 2
n
−1 such subsets. Even if you use
clever tricks to reduce the number of possible solutions, you are still in exponential
territory in the worse case. But you can non-deterministically guess a solution and
test it in linear time; but no one has found any way of producing a correct solution
deterministically in less than
Θ
(2
n
) steps.
One of the great unsolved problems in theoretical computer science is does P =
NP? That is, is the set of problems that can be solved in polynomial time on a
non-deterministic machine the same as the set of problems that can be solved in
polynomial time on a deterministic machine? It is clear that that P ⊆ NP, that is,
that all problems that can be solved in polynomial time on a deterministic machine
can also be solved in polynomial time on a non-deterministic machine. Although it
is a commonly accepted hypothesis that P = NP no one has been able to prove it to
date.
Within NP, there is a set of particularly interesting problems which are called
NP-complete. The idea of an NP-complete problem is that it is one of the hardest
problems in NP or, in other words, is one where we can prove that if there is a P-
time computation that solves the problem, it would mean that there was a P-time
solution for every problem in NP, and thus P = NP.
How do we show that a given problem is NP-complete? NP-completeness is
based on the idea of problem reduction. Given two problems S and T for which it
can be shown that any instance of S can be transformed into an instance of T in
polynomial time, it is said that S is polynomial-time reducible to T. Therefore, if an
efficient algorithm to solve problem T is known, this algorithm can also be used to
solve problem S. It can be seen as S is easier than T .
Once we know a problem T which is NP-complete, then for any other problem
U, if we can show that T is polynomial-time reducible to U, then U must be NP-