Here are the answers to your questions:
Q.1) There are two main classes of NP problems:
- NP-Complete problems: Problems that are in NP and are at least as hard as any other problem in NP. This means if you can efficiently solve one NP-Complete problem, then you can efficiently solve any problem in NP.
- NP-Hard problems: Problems at least as hard as the hardest problems in NP. NP-Hard problems may not necessarily be in NP.
Q.2) A nondeterministic algorithm is one that, at some step, can choose from multiple possible choices without a clear deterministic rule for how to pick the choice. It is modeled as having the ability to "guess" the right
2. NP-Hard and NP-Complete Problems
For many of the problems we know and study, the best
algorithms for their solution have computing times can be
clustered into two groups-
1. Solutions are bounded by the polynomial
2. Solutions are bounded by a nonpolynomial
3. No one has been able to device an algorithm which is bounded
by the polynomial of small degree for the problems belonging
to the second group.
The theory of the NP-Completeness does not provide any
method of obtaining polynomial time algorithms for the
problems of the second group. Many of the problems for
which there is no polynomial time algorithm available are
computationally related.
Perhaps with Quantum Computing ! Who knows? Open ?
4. Two classes
1. NP-Complete- have the property that it can be solved
in polynomial time if all other NP-Complete problems
can be solved in polynomial time.
2. NP-Hard- if it can be solved in polynomial time then
all NP-Complete can be solved in polynomial time.
6. All NP-Complete problems are NP-Hard but not all NP-
Hard problems are not NP-Complete.
NP-Complete problems are subclass of NP-Hard
Non deterministic algorithms
When the result of every operation is uniquely defined then it
is called deterministic algorithm. When the outcome is not
uniquely defined but is limited to a specific set of possibilities,
we call it non deterministic algorithm.
7. We use new statements to specify such algorithms.
1. choice(S) arbitrarily choose one of the elements of set S
2. failure signals an unsuccessful completion
3. success signals a successful completion
The assignment X:= choice(1:n) could result in X being
assigned any value from the integer range[1..n]. There is no
rule specifying how this value is chosen.
8. The nondeterministic algorithms terminates unsuccessfully
iff there is no set of choices which leads to the successful
signal.
The computing time for failure and success is taken to be
O(1). A machine capable of executing a nondeterministic
algorithms are known as nondeterministic machines (does not
exist in practice).
9. Ex. Searching an element x in a given set of elements A(1:n).
We are required to determine an index j such that A(j) = x or j
= 0 if x is not present.
j := choice(1:n)
if A(j) = x then print(j); success endif
print(0); failure
10. procedure NSORT(A,n);
//sort n positive integers//
var integer A(n), B(n), n, i, j;
begin
B := 0; //B is initialized to zero//
for i := 1 to n do
begin
j := choice(1:n);
if B(j) <> 0 then failure;
B(j) := A(j);
end;
11. for i := 1 to n-1 do //verify order//
if B(i) > B(i+1) then failure;
print(B);
success;
end.
12. Nondeterministic machines does not make any copies of an
algorithm every time a choice is to be made. Instead it has
the ability to correctly choose an element from the given set.
A deterministic interpretation of the nondeterministic
algorithm can be done by making unbounded parallelism in
the computation.
Each time a choice is to be made, the algorithm makes several
copies of itself, one copy is made for each of the possible
choices.
13. Nondeterministic decision algorithm- Generates 0 or 1 as
their output.
Many optimization problems can be recast in to decision
problems with the property that the decision algorithm can be
solved in polynomial time iff the corresponding optimization
problem.
Definition: The time required by a nondeterministic
algorithm performing on any given input is the minimum
number of steps required to reach to a successful completion if
there exists a sequence of choices leading to a such
completion.
14. In case the successful completion is not possible then the
time required is O(1). A nondeterministic algorithm is of
complexity O(f(n)) if for all input size n, n n0, that results
in a successful completion the time required is at most c.f(n)
for some constant c and n0.
15. procedure DKP(P, W, n, M, R, X);
var integer P(n), W(n), R, X(n), n, M, i;
begin
for i := 1 to n do
X(i) := choice(1, 0);
if or then failure
else success;
end.
n
i
M
i
X
i
W
1
))
(
)
(
(
n
i
R
i
X
i
P
1
))
(
)
(
(
Time complexity is O(n).
16. Satisfiability problem: Let x1,x2,...,xn denotes boolean
variables. Let denotes the negation of xi. A literal is either a
variable or its negation. A formula in propositional calculus is
an expression that can be constructed using literals and and or
or.
i
x
Formula is in conjugate normal form (CNF) iff it is
represented as ci, where the ci are clauses each represented
as V lij.
k
i 1
It is in disjunctive normal form (DNF) iff it is represented as
ci and each clause is represented as lij.
k
i 1
17. thus is in DNF while
is in CNF. The satisfiability problem is to determine if a
formula is true for some assignment of truth values to the
variables.
)
(
)
( 4
3
2
1 x
x
x
x
)
(
)
( 2
1
4
3 x
x
x
x
procedure EVAL(E, n);
//determines if the propositional formula E is satisfiable//
var boolean: x[1..n];
begin
for i := 1 to n do //choose a truth value assignment//
xi := choice(true, false);
if E(x1,...,xn) is true then success //satisfiable//
else failure
end.
18. NP-Hard and NP-Complete
An algorithm A is of polynomial complexity is there exist a
polynomial p( ) such that the computing time of A is O(p(n)).
Definition: P is a set of all decision problems solvable by a
deterministic algorithm in polynomial time. NP is the set of all
decision problems solvable by a nondeterministic algorithm in
polynomial time.
NP
P
19. The most famous unsolved problem in Computer Science is
whether P=NP or NP
P NP
P
?
Cooks theorem: Satisfiability is in P if P = NP
Definition. Let L1 and L2 be problems. L1 reduces to L2( )
iff there is a way to solve L1 by deterministic polynomial time
algorithm that solve L2 in polynomial time.
2
1 L
L
20. if we have a polynomial time algorithm for L2 then we can
solve L1 in polynomial time.
Definition. A problem L is NP-Hard if and only if
satisfiability reduces to L. ( ).
L
lity
satisfiabi
Definition. A problem L is NP-Complete if and only if L is
NP-Hard and .
NP
L
Halting problem: An example of NP-Hard decision problem
which is not NP-Complete.
21. Assignment
Q.1)What are the classes of NP problem?
Q.2)Explain nondeterministic algorithm with an
example.
Q.3)Which problem is NP prpblem?