A shortened version of the pertinent facts is also available.
These notes contains the information on the overhead slides used in class.
A decision problem (yes/no question) is in the class P if there is a polynomial time algorithm for solving it. Polynomial time means O(nc) for some constant c. If a problem is solvable in polynomial time for
Most algorithms you have studied run in polynomial time. For example, the Minimum Spanning Tree Algorithms for CSC 225. To be in P, we must however have a decision problem. But Minimum Spanning Tree can be reformulated as a decision problem by adding an integer k as part of the input, and then asking whether G has a spanning tree of weight at most k. If you are provided with a tree with weight at most k as part of the solution, the answer can be verified in O(n2) time.
This distinction is made between polynomial time and anything else (sometimes referred to as exponential time) because of the blowup in computation times (click here for some examples) which appear for exponential algorithms.
A decision problem (yes/no question) is in the class NP if it has a nondeterministic polynomial time algorithm. Informally, such an algorithm:
So to show a problem is in NP you must ensure:
Because both the yes and the no answers can be verified in polynomial time for any problem which is in class P, all problems in P are also in NP. The formeost open question in computer science is whether P=NP. Or equivalently, if there exists any problem in NP that cannot be solved in polynomial time.
Some examples of problems in NP but not known to be in P are Hamilton Path, and Hamilton Cycle. One of the exercises for the latest assignment is to prove that a purported solution for Hamilton Path can be checked in O(n) time, thus proving that there is a nondeterministic polynomial time algorithm for Hamilton Path.
The Clique Problem is another example of a problem in NP but not known to be in P. The input is a graph G and an integer k, and the the question is whether H has a clique (a subset of the vertices which are pairwise adjacent) which contains k or more vertices.
A brute force recursive algorithm for solving Clique
can be obtained from the following observation:
Clique(G, k)= Clique(Nv, k-1) or Clique(G-v, k),
where Nv is the subgraph induced by the
neighbours of vertex v in G.
The time complexity for this algorithm is O(n2 2n).
No substantially better algorithms are known!
It would be nice to be able to prove that problems such as Hamilton Path and Clique have no polynomial time algorithms. But we do not currently know how to do this. The next best thing when you cannot find a polynomial time algorithm for a problem is to show that nobody else can either.
The class of problems in NP which are the "hardest" are called the NP-complete problems. More formally, a problem Q in NP is NP-complete if the existence of a polynomial time algorithm for Q implies the existence of a polynomial time algorithm for all problems in NP.
Next: SAT, the First NP-complete Problem