0% found this document useful (0 votes)
18 views4 pages

Wa0001.

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

Wa0001.

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

There are two classes of non-polynomial time problems

1. NP-Hard
2. NP-Complete
NP Complete Problem: A problem that is NP-Complete can solved in polynomial time
if and only if (iff) all other NP-Complete problems can also be solved in polynomial time.

NP-Hard: Problem can be solved in polynomial time then all NP-Complete problems can
be solved in polynomial time.

All NP-Complete problems are NP-Hard but some NP-Hard problems are not know to be NP-
Complete.

Nondeterministic Algorithms:

Algorithms with the property that the result of every operation is uniquely defined are
termed as deterministic algorithms. Such algorithms agree with the way programs are
executed on a computer.

Algorithms which contain operations whose outcomes are not uniquely defined but
are limited to specified set of possibilities. Such algorithms are called
nondeterministic algorithms.

The machine executing such operations is allowed to choose any one of these
outcomes subject to a termination condition to be defined later.

To specify nondeterministic algorithms, there are 3 new

sful completion

Example for Non Deterministic algorithms:


Algorithm Search(x){ Whenever there is a set of choices
that leads to a successful
//Problem is to search an element x
completion then one such set of
//output J, such that A[J]=x; or J=0 if x is not choices is always made and the
in A J:=Choice(1,n); algorithm terminates.

if( A[J]:=x) then { A Nondeterministic algorithm


Write(J); terminates unsuccessfully if and
only if (iff) there exists no set of
Success()
choices leading to a successful
; signal.
}
else{
write(0)
;
failure()
;
}

Nondeterministic Knapsack algorithm

Algorithm DKP(p, w, n, m, r, x){


W:=0;
P:=0;
for i:=1 to n do{ p or w)
x[i]:=choice(0, 1);
W:=W+x[i]*w[i];
P:=P+x[i]*p[i];
}
if( (W>m) or (P<r) ) then Failure();
else Success();
}
The Classes NP-Hard & NP-Complete:
For measuring the complexity of an algorithm, we use the input length as the
parameter. For example, An algorithm A is of polynomial complexity p() such that the
computing time of A is O(p(n)) for every input of size n.
Decision problem/ Decision algorithm: Any problem for which the answer is either
zero or one is decision problem. Any algorithm for a decision problem is termed a
decision algorithm.
Optimization problem/ Optimization algorithm: Any problem that involves the
identification of an optimal (either minimum or maximum) value of a given cost
function is known as an optimization problem. An optimization algorithm is used to
solve an optimization problem.

P
polynomial time.
is the set of all decision problems solvable by nondeterministic algorithms
in polynomial time.

Since deterministic algorithms are just a special case of nondeterministic, by this


we concluded that P ⊆ NP

Commonly believed relationship between P & NP


The most famous unsolvable problems in Computer Science is Whether P=NP or
P≠NP In considering this problem, s.cook formulated the following question.

If there any single problem in NP, such that if we showed it to be in ‘P’ then that
would imply that P=NP.

Cook answered this question with

Theorem: Satisfiability is in P if and only if (iff) P=NP

Let L1 and L2 be problems, Problem L1 reduces to L2 (written L1 α L2) iff there is a


way to solve L1 by a deterministic polynomial time algorithm using a deterministic
algorithm that solves L2 in polynomial time

This implies that, if we have a polynomial time algorithm for L 2, Then we can solve L1 in
polynomial time.

L1 α L2 and L2 α L3 then L1 α L3

A problem L is NP-Hard if and only if (iff) satisfiability reduces to L ie., Statisfiability α L

A problem L is NP-Complete if and only if (iff) L is NP-Hard and L Є NP


Commonly believed relationship among P, NP, NP-Complete and NP-Hard

Most natural problems in NP are either in P or NP-complete.


Examples of NP-complete problems:
 Packing problems: SET-PACKING, INDEPENDENT-SET.
 Covering problems: SET-COVER, VERTEX-COVER.
 Sequencing problems: HAMILTONIAN-CYCLE, TSP.
 Partitioning problems: 3-COLOR, CLIQUE.
 Constraint satisfaction problems: SAT, 3-SAT.
 Numerical problems: SUBSET-SUM, PARTITION, KNAPSACK.
Cook’s Theorem: States that satisfiability is in P if and only if
P=NP If P=NP then satisfiability is in P
If satisfiability is in P, then
P=NP To do this

algorithm
Then formula Q(A, I), Such that Q is satisfiable iff ‘A’ has a successful
termination with Input I.
 If the length of ‘I’ is ‘n’ and the time complexity of A is p(n) for some
polynomial p() then length of Q is O(p3(n) log n)=O(p4(n))
The time needed to construct Q is also O(p3(n) log n).

 A deterministic algorithm ‘Z’ to determine the outcome of ‘A’ on any


input ‘I’
Algorithm Z computes ‘Q’ and then uses a deterministic algorithm for the
satisfiability problem to determine whether ‘Q’ is satisfiable.
 If O(q(m)) is the time needed to determine whether a formula of length
‘m’ is satisfiable then the complexity of ‘Z’ is O(p3(n) log n +

q(p3(n)log n)).
 If satisfiability is ‘p’, then ‘q(m)’ is a polynomial function of ‘m’ and the
complexity of ‘Z’ becomes ‘O(r(n))’ for some polynomial ‘r()’.

 Hence, if satisfiability is in p, then for every nondeterministic algorithm A


in NP, we can obtain a deterministic Z in p.
By this we shows that satisfiability is in p then P=NP

You might also like