0% found this document useful (0 votes)
26 views8 pages

Daa Unit-V

Daa

Uploaded by

saiphani9876
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)
26 views8 pages

Daa Unit-V

Daa

Uploaded by

saiphani9876
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/ 8

UNIT V: NP-Hard and NP-Complete problems

Basic concepts, non-deterministic algorithms, NP - Hard and NP-Complete classes, Cook’s theorem.
…………………………………………………………………………………………………………………..

1. Basic concepts:
NP-Nondeterministic Polynomial time.
The problems has best algorithms for their solutions have “Computing times”, that cluster into two
groups.

No one has been able to develop a polynomial time algorithm for any problem in the 2nd group
(i.e., group 2)
So, it is compulsory and finding algorithms whose computing times are greater than polynomial very
quickly because such vast amounts of time to execute that even moderate size problems cannot be
solved.

2. Deterministic and non-deterministic algorithms


Deterministic: The algorithm in which every operation is uniquely defined is called deterministic
algorithm.
Non-Deterministic: The algorithm in which the operations are not uniquely defined but are limited
to specific set of possibilities for every operation, such an algorithm is called non-deterministic
algorithm.
The non-deterministic algorithms use the following functions:
1. Choice: Arbitrarily chooses one of the element from given set.
2. Failure: Indicates an unsuccessful completion
3. Success: Indicates a successful completion.
A non-deterministic algorithm terminates unsuccessfully if and only if there exists no set of choices
leading to a success signal. Whenever, there is a set of choices that leads to a successful completion,
then one such set of choices is selected and the algorithm terminates successfully.
In case the successful completion is not possible, then the complexity is O(1). In case of successful
signal completion then the time required is the minimum number of steps needed to reach a successful
completion of O(n) where n is the number of inputs.
The problems that are solved in polynomial time are called tractable problems and the problems that
require super polynomial time are called non-tractable problems. All deterministic polynomial time
algorithms are tractable and the non-deterministic polynomials are intractable.
Satisfiability Problem:
The satisfiability is a boolean formula that can be constructed using the
following literals and operations.
1. A literal is either a variable or its negation of the variable.
2. The literals are connected with operators ˅, ˄͢, ⇒ , ⇔
3. Parenthesis
The satisfiability problem is to determine whether a Boolean formula is true for some assignment of
truth values to the variables. In general, formulas are expressed in Conjunctive Normal Form (CNF).
A Boolean formula is in conjunctive normal form iff it is represented by

( xi ∨ xj ∨ xk1 ) ∧ ( xi ∨ x 1 ∨ xk )
A Boolean formula is in 3CNF if each clause has exactly 3 distinct literals.
Example:
The non-deterministic algorithm that terminates successfully iff a given formula E(x1,x2,x3) is
satisfiable.

Reducability:
A problem Q1 can be reduced to Q2 if any instance of Q1 can be easily rephrased as an instance of
Q2. If the solution to the problem Q2 provides a solution to the problem Q1, then these are said to
be reducable problems.
Let L1 and L2 are the two problems. L1 is reduced to 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 and is
denoted by L1α L2. If we have a polynomial time algorithm for L2 then we can solve L1 in polynomial
time.
Two problems L1 and L2 are said to be polynomially equivalent iff L1α L2 and L2 α L1.
Example: Let P1 be the problem of selection and P2 be the problem of sorting. Let the input have n
numbers. If the numbers are sorted in array A[ ] the ith smallest element of the input can be obtained
as A[i]. Thus P1 reduces to P2 in O(1) time.
Decision Problem:
Any problem for which the answer is either yes or no is called decision problem. The algorithm for
decision problem is called decision algorithm.
Example: Max clique problem, sum of subsets problem.
Optimization Problem: Any problem that involves the identification of an optimal value (maximum
or minimum) is called optimization problem.
Example: Knapsack problem, travelling salesperson problem.
In decision problem, the output statement is implicit and no explicit statements are permitted.
The output from a decision problem is uniquely defined by the input parameters and algorithm
specification.
Many optimization problems can be reduced by decision problems with the property that a decision
problem can be solved in polynomial time iff the corresponding optimization problem can be solved
in polynomial time. If the decision problem cannot be solved in polynomial time then the
optimization problem cannot be solved in polynomial time.
3. NP - Hard and NP-Complete classes
P-is the set of all decision problems solvable by deterministic algorithms in polynomial time.
NP-is the set of all decision problems solvable by nondeterministic algorithms inpolynomial time.

Since deterministic algorithms are just a special case of nondeterministic, by this we concluded that
P⊆NP
The nondeterministic polynomial time problems
can be classified into two classes. They are
1. NP Hard and
2. NP Complete
NP-Hard: A problem L is NP-Hard iff satisfiability reduces to L i.e., any nondeterministic polynomial
time problem is satisfiable and reducable then the problem is said to be NP-Hard.
Example: Halting Problem, Flow shop scheduling problem
NP-Complete: A problem L is NP-Complete iff L is NP-Hard and L belongs to NP (nondeterministic
polynomial).
A problem that is NP-Complete has the property that it can be solved in polynomial time iff all
other NP-Complete problems can also be solved in polynomial time. (NP=P).
If an 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 NPhard problems are
not known to be NP- Complete.
Normally the decision problems are NP-complete but the optimization problems are NPHard.
However if problem L1 is a decision problem and L2 is an optimization problem, then it is possible
that L1α L2.
Example: Knapsack decision problem can be reduced to knapsack optimization problem.
There are some NP-hard problems that are not NP-Complete
Relationship between P,NP,NP-hard, NP-Complete
Let P, NP, NP-hard, NP-Complete are the sets of all possible decision problems that are solvable in
polynomial time by using deterministic algorithms, non-deterministic algorithms, NP-Hard and NP-
complete respectively. Then the relationship between P, NP, NP-hard, NP-Complete can be expressed
using Venn diagram as:
4. Cook’s theorem.
In computational complexity theory, the Cook–Levin theorem, also known as Cook’s theorem, states
that the Boolean satisfiability problem is NP-complete. That is, it is in NP, and any problem in NP
can be reduced in polynomial time by a deterministic Turing machine to the Boolean satisfiability
problem.
Stephen Arthur Cook and L.A. Levin in 1973 independently proved that the satisfiability
problem(SAT) is NP-complete. Stephen Cook, in 1971, published an important paper titled ‘The
complexity of Theorem Proving Procedures’, in which he outlined the way of obtaining the proof of
an NP-complete problem by reducing it to SAT. He proved Circuit-SAT and 3CNF-SAT problems are
as hard as SAT. Similarly, Leonid Levin independently worked on this problem in the then Soviet
Union. The proof that SAT is NP-complete was obtained due to the efforts of these two scientists.
Later, Karp reduced 21 optimization problems, such as Hamiltonian tour, vertex cover, and clique,
to the SAT and proved that those problems are NP-complete.
Hence, an SAT is a significant problem and can be stated as follows:
Given a boolean expression F having n variables x1,x2,….,xn, and Boolean operators, is it possible to
have an assignment for variables true or false such that binary expression F is true?
This problem is also known as the formula – SAT. An SAT(formula-SAT or simply SAT) takes a Boolean
expression F and checks whether the given expression(or formula) is satisfiable. A Boolean expression
is said to be satisfactory for some valid assignments of variables if the evaluation comes to be true.
Prior to discussing the details of SAT, let us now discuss some important terminologies of a Boolean
expression.
• Boolean variable: A variable, say x, that can have only two values, true or false, is called a
boolean variable
• Literal: A literal can be a logical variable, say x, or the negation of it, that is x or x̄; x is called
a positive literal, and x̄ is called the negative literal
• Clause: A sequence of variables(x1,x2,….,xn) that can be separated by a logical OR operator is
called a clause. For example, (x1 V x2 V x3) is a clause of three literals.
• Expressions: One can combine all the preceding clauses using a Boolean operator to form an
expression.
• CNF form: An expression is in CNF form(conjunctive normal form) if the set of clauses are
separated by an AND (^), operator, while the literals are connected by an OR (v) operator.
The following is an example of an expression in the CNF form:
o f = (x1 V x̄2 V x3) ∧ (x1 V x̄3 V x2)
• 3 – CNF: An expression is said to be in 3-CNF if it is in the conjunctive normal form, and every
clause has exact three literals.
Thus, an SAT is one of the toughest problems, as there is no known algorithm other than the brute
force approach. A brute force algorithm would be an exponential-time algorithm, as 2n possible
assignments need to be tried to check whether the given Boolean expression is true or not. Stephen
Cook and Leonid Levin proved that the SAT is NP-complete.
Cook demonstrated the reduction of other hard problems to SATs. Karp provided proof of 21
important problems, Such as Hamiltonian tour, vertex cover, and clique, by reducing it to SAT using
Karp reduction.
Let us briefly introduce the three types of SATs. They are as follows:
1. Circuit- SAT: A circuit-SAT can be stated as follows: given a Boolean circuit, which is a collection
of gates such as AND, OR, and NOT, and n inputs, is there any input assignments of Boolean
variables so that the output of the given circuit is true? Again, the difficulty with these problems
is that for n inputs to the circuit. 2n possible outputs should be checked. Therefore, this brute
force algorithm is an exponential algorithm and hence this is a hard problem.
2. CNF-SAT: This problem is a restricted problem of SAT, where the expression should be in a
conjunctive normal form. An expression is said to be in a conjunction form if all the clauses
are connected by the Boolean AND operator. Like in case of a SAT, this is about assigning truth
values to n variables such that the output of the expression is true.
3. 3-CNF-SAT(3-SAT): This problem is another variant where the additional restriction is that the
expression is in a conjunctive normal form and that every clause should contain exactly three
literals. This problem is also about assigning n assignments of truth values to n variables of the
Boolean expression such that the output of the expression is true. In simple words, given an
expression in 3-CNF, a 3-SAT problem is to check whether the given expression is satisfiable.
These problems can be used to prove the NP-completeness of some important problems.

You might also like