Sei sulla pagina 1di 4

P, NP-Complete, NP, and NP-Hard

Optimization Problem

Optimization problems are those for which the objective is to maximize or minimize some values.
For example, finding the minimum number of colors needed to color a given graph. Finding the
shortest path between two vertices in a graph.

Decision Problem

There are many problems for which the answer is a Yes or a No. These types of problems are
known as decision problems. For example, whether a given graph can be colored by only 4-
colors. Finding Hamiltonian cycle in a graph is not a decision problem, whereas checking a graph
is Hamiltonian or not is a decision problem.

Deterministic Algorithm

When the result of every operation is uniquely defined then it is called deterministic algorithm.

Non Deterministic Algorithm

When the outcome is not uniquely defined but is limited to a specific set of possibilities, we call it
non deterministic algorithm.

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

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. (Except quantum computing open problem)
The theory of the NP-Completeness does not provide any method of obtaining polynomial time
algorithms for the problems of the second group.

P-Class

The class P consists of those problems that are solvable in polynomial time, which take time like
O(n), O(n2), O(n3). i.e. these problems can be solved in time O(nk) in worst-case, where k is
constant. Algorithms such as Matrix Chain Multiplication, Single Source Shortest Path, All Pair
Shortest Path, Minimum Spanning Tree, etc. run in polynomial time. For input size n, if worst-
case time complexity of an algorithm is O(nk), where k is a constant, the algorithm is a
polynomial time algorithm. These problems are called tractable/ controllable (easy to control or
manageable), while others are called intractable or super polynomial
Formally, an algorithm is polynomial time algorithm, if there exists a polynomial p(n) such that
the algorithm can solve any instance of size n in a time O(p(n )).
Problem requiring Ω(n50) time to solve are essentially intractable for large n. Most known
polynomial time algorithm run in time O(nk) for fairly low value of k.

NP-Class

1. 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.
2. Non deterministic Polynomial time solving means that “problem which can't be solved in
polynomial time like TSP( travelling salesman problem) The class NP consists of those
problems that are verifiable/checkable means that given a solution of a problem , we can
check that whether the solution is correct or not in polynomial time. NP is the class of
decision problems for which it is easy to check the correctness of a claimed answer, with
the aid of a little extra information. Hence, we aren’t asking for a way to find a solution,
but only to verify that an alleged solution really is correct. Every problem in this class can
be solved in exponential time using exhaustive search.

P versus NP

Every decision problem that is solvable by a deterministic polynomial time algorithm is also
solvable by a polynomial time non-deterministic algorithm.

All problems in P can be solved with polynomial time algorithms, whereas all problems in NP - P
are intractable/ uncontrollable, (hard to control or deal with or unmanageable).

It is not known whether P = NP. However, many problems are known in NP with the property
that if they belong to P, then it can be proved that P = NP.

If P ≠ NP, there are problems in NP that are neither in P nor in NP-Complete.

The problem belongs to class P if it’s easy to find a solution for the problem. The problem
belongs to NP, if it’s easy to check a solution that may have been very tedious (too long / slow) to
find.

Reducibility- Take two problems A and B both are NP problems. If we can convert one instance
of a problem A into problem B (NP problem) then it means that A is reducible to B.

NP-Complete-

1. Have the property that it can be solved in polynomial time if all other NP-Complete
problems can be solved in polynomial time.
2. A problem is in the class NPC if it is in NP and is as hard as any problem in NP. If a
polynomial time algorithm exists for any of these problems, all problems in NP would be
polynomial time solvable. These problems are called NP-complete.
3. The group of problems which are both in NP and NP-hard are known as NP-Complete
problem. However there are many problems, such as traveling salesperson, optimal graph
coloring, Hamiltonian cycles, finding the longest path in a graph, and satisfying a Boolean
formula, for which no polynomial time algorithms is known. These problems belong to an
interesting class of problems, called the NP-Complete problems, whose status is
unknown.
4. Some NP-Complete problems, for which no polynomial time algorithm is known are
 Determining whether a graph has a Hamiltonian cycle
 Determining whether a Boolean formula is satisfiable
 TSP
 Graph Coloring

NP-Hard-

1. If it can be solved in polynomial time then all NP-Complete can be solved in polynomial
time.
2. A problem is NP-hard if all problems in NP are polynomial time reducible to it, even
though it may not be in NP itself.
3. Let A is reducible to B, then it means that B is at least as hard as A.
4. The following problems are NP-Hard
 The circuit-satisfiability problem
 Set Cover
 Vertex Cover
 Travelling Salesman Problem

“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

Definition of NP-Completeness

A language B is NP-complete if it satisfies two conditions


 B is in NP
 Every A in NP is polynomial time reducible to B.
If a language satisfies the second property, but not necessarily the first one, the language B is
known as NP-Hard
The problem in NP-Hard cannot be solved in polynomial time, until P = NP. If a problem is
proved to be NPC, there is no need to waste time on trying to find an efficient algorithm for it.
Instead, we can focus on design approximation algorithm.

NP-Hard and NP-Complete

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.

⇒ P ⊆ NP

Is P ≠ NP?

P = NP means that for all problems whose solutions can be efficiently verified, the solutions can
be efficiently generated too.

It is widely believed that P ≠ NP.

This problem is listed as one of the seven most important unsolved problems in mathematics that
either P = NP or P ≠NP!

Cook’s theorem: Satisfiability is in P if P = NP

Definition. Let L1 and L2 be problems. L1 reduces to L2 (L1 α L2) iff there is a way to solve L1
by deterministic polynomial time algorithm that solve L2 in polynomial time.

⇒ If we have a polynomial time algorithm for L2 then we can solve L1 in polynomial time.

Definition: - A problem L is NP-Hard iff satisfiability reduces to L (satisfiability α L).

Definition: - A problem L is NP-Complete if and only if L is NP-Hard and L NP.

Halting problem:- An example of NP-Hard decision problem which is not NP-Complete.

Potrebbero piacerti anche