Limitation of Computation Power - P, NP, and NP-complete Class P
Limitation of Computation Power - P, NP, and NP-complete Class P
Class P
Definition 1 Class P is a class of decision problems that can be solved in
polynomial time by (deterministic) algorithms. This class of problems is
called polynomial.
Class NP
There is a large number of important problems, for which no polynomial-
time algorithm has been found, nor has the impossibility of such an
algorithm has been proved. Some samples are:
• Knapsack problem Find the most valuable subset of n items of given
positive integer weights and values that fit into a knapsack of a given
positive integer capacity.
• Hamiltonian circuit Determine whether a given graph as a Hamiltonian circuit (a
path that starts and ends at the same vertex and passes through all the other vertices
exactly once).
• Traveling salesman Find the shortest tour through n cities with known positive
integer distances between them.
• Graph coloring For a given graph, find its chromatic number (the smallest number
of colors that need to be assigned to the graph’s vertices so that no two adjacent
vertices are assigned the same color).
• 3 - CNF - SAT Problem A 3 - CNF is a conjunctive normal form (CNF) F , which is an
AND of clauses and each of clause is the OR of 3 boolean variables from x1 / x1 , x2 / x2 ,
..., xn / xn . If there is a set of value of x1 , x2 ,..., xn such that F 1 then F is satisfiable,
otherwise F is unsatisfiable. The problem is that given an F decide if F is satisfiable
or not.
Example of Traveling sales man problem
2 Tour length
a b
8 7 3 abcda 18
5
c d abdca 11
1
…
Totally there are P(4,4)=4! tours.
Since the number of the subsets from n elements is 2 n , the computing time is O(2 n ).
People couldn’t find a good algorithm (using polynomial time) to solve it !
Definition 2 A nondeterministic algorithm is a two-stage procedure that takes as
its input an instance I of a decision problem and does the following.
• Nondeterministic (“guess”) stage: generate a candidate solution S to the given
instance I.
• Deterministic (“verification”) stage: A deterministic algorithm takes both I and
S as its input, and it outputs yes if S is a solution to instance I.
Definition 3 Class NP is the class of decision problems that that can be solved by
nondeterministic polynomial algorithms. This class of problems is called
nondeterministic polynomial.
Famous Problem: P = NP ?
Class NP-complete
Definition 3 A decision problem D1 is said to be polynomially reducible to
a decision problem D2 if there exists a function t that transforms instances
of D1 to instances of D2 such that
• t maps all yes instances of D1 to yes instances of D2 and no instances of
D1 to no instances of D2;
• t is computable by a polynomial-time algorithm.
Class NP