0% found this document useful (0 votes)
11 views7 pages

Limitation of Computation Power - P, NP, and NP-complete Class P

The document discusses the classifications of decision problems in computational complexity, specifically Class P, NP, and NP-complete. Class P includes problems solvable in polynomial time, while Class NP consists of problems for which no polynomial-time algorithms are known. NP-complete problems are those that are both in NP and to which all NP problems can be reduced in polynomial time, raising the famous question of whether P equals NP.

Uploaded by

Mridul Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views7 pages

Limitation of Computation Power - P, NP, and NP-complete Class P

The document discusses the classifications of decision problems in computational complexity, specifically Class P, NP, and NP-complete. Class P includes problems solvable in polynomial time, while Class NP consists of problems for which no polynomial-time algorithms are known. NP-complete problems are those that are both in NP and to which all NP problems can be reduced in polynomial time, raising the famous question of whether P equals NP.

Uploaded by

Mridul Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 7

Limitation of Computation Power – P, NP, and NP-complete

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

Given a graph G, find the shortest simple circuit (Hamiltonian circuit)


in G which passes through all the vertices.

2 Tour length
a b
8 7 3 abcda 18
5
c d abdca 11
1

Totally there are P(4,4)=4! tours.

Generally, there may have n! tours in a graph of n vertices and if we


check all the tours the computing time is O(n!).
People couldn’t find a good algorithm (using polynomial time) to solve it!
Example of Knapsack problem
Given n items of known weights w1 , w2 ,..., wn and values v1 , v2 ,..., vn and a knapsack
of capacityW , find the most valuable subset of the items that fit into the knapsack.
knapsack: W=10
item 1: w=7, v=$42 item 2: w=3, v=$12, item 3: w=4, v= $40, item 4: w=5, v=$25
Search for solution :
Subset  , {1},{2},{3},{4},{1,2},{1,3},{1,4},{2,3},{2,4},{3,4},{1,2,3},{1,2,4},{1,3,4},{2,3,4},{1,2,3,4}
Total wight 0, 7, 3, 4, 5, 10, 11, 12, 7, 8, 9, 14, 15, 16, 12, 19
Total value $0, $42, $12, $40, $25, $36, , , $52, $37, $65, , , , , 

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.

If a problem D1 polynomially reducible to some problem D2 that can


be solved in polynomial time, then problem D1 can also be solved in
polynomial time.

Definition 4 A decision problem D is said to be NP-complete if


1. It belongs to class NP;
2. Every problem in NP is polynomially reducible to D.
Class P-complete Class P

Class NP

You might also like