How do problems get classified?
Computer theoretitions like to divide problems into
classes, based on how fast we expect that the problem can be solved.
This gives us a greater understanding of which problems we should be trying
to find algorithms to solve, and which problems we should accept as inherently
difficult. The following are some of the classes that algorithms
are classified into. Much of the work that computer theoretitians
to is trying to figure out which class a certain problem belongs to.
P
The class "P" is the class of all problems that
can be solved in polynomial time. The most straightforward way to
classify a problem in P is to find an algorithm which solves the
problem that has a polynomial running time.
NP
The class "NP" is the class of all problems which
can be verified in polynomial time. This means that, if you were
to give me a solution to the problem, then I could verify that your solution
is correct in a polynomial amount of time. This does not necessarily
mean that I would have been able to find your solution in a polynomial
amount of time.
All problems that are in either of the classes
"P" or "NP-Complete" are also in "NP".
NP-Complete
The techincal definition of this class is "as difficult
as any problem in NP, yet still in NP". This means that there are
no problems in "NP" whose running times have a higher order than this problem.
A practical way of thinking of this class is that, if one problem in this
class could be solved in a polynomial amount of time, then every problem
in the entire class "NP" would then be solvable in polynomial time.
The standard method for showing that a problem is
in this class is to perform a reduction from another problem which is already
known to be in this class. A reduction generally involves proving
the statement "If I could solve problem Q in a certain amount of time,
then I would be able to solve problem R in a comparable amount of time".
Consider that you have a problem Q which you want
to classify, and you have a problem R which is known to be NP-Complete.
Now consider that you can prove the following statement: "If Q can
be solved in polynomial time, then R can also be solved in polynomial time".
This then would be (almost) enough to show that problem Q is NP-Complete.
That is, if I want to show that Q is NP-Complete, one thing I could do
is to show that if I could find an algorithm which solves Q polynomial
time, then I could create the following algorithm which will solve R in
polynomial time:
-
Take a given input for R
-
Translate that input for P into a proper input for Q
-
Use the polynomial time alorithm for Q (which likely doesn't exist) to
solve this problem
-
Translate the solution for Q into a solution for R
The result of all this is that we now can state the following: "If there
does not exist any polynomial time algorithm which solves R, then there
does not exist any polynomial time algorithm which solves Q". It
is widely believed (but never proven) among experts, that problems which
are NP-Complete cannot be solved with polynomial time algorithms.
To completely prove that a problem is NP-Complete,
it is also necessary to show that the problem is in "NP" (without this,
the problem is classefied as NP-Hard).
NP-Hard
This class is similar to the class "NP-Complete",
but without the restriction that the problem belong to "NP". All
problems which are in "NP-Complete", are also in "NP-Hard".