5CS4-AOA-Unit-5 - PPT @zammers
5CS4-AOA-Unit-5 - PPT @zammers
Jaipur
1
Complexity Classes
P class
NP Class
NP-Hard Class
NP-Complete Class
Classification of Problems
In Computer Science, many problems are solved
where the objective is to maximize or minimize
some values, whereas in other problems we try
to find whether there is a solution or not. Hence,
the problems can be categorized as follows −
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,
We could then inspect the graph and check that this is indeed a
legal cycle and that it visits all of the vertices of the graph exactly
once. Thus, even though we know of no efficient way to solve the
Hamiltonian cycle problem, there is a beneficial way to verify that a
given cycle is indeed a Hamiltonian cycle.
Note:-For the verification in the Polynomial-time of an undirected
Hamiltonian cycle graph G. There must be exact/specific/definite
path must be given of Hamiltonian cycle then you can verify in the
polynomial time.
Reductions
The class NP-complete (NPC) problems consist of a set of
decision problems (a subset of class NP) that no one knows
how to solve efficiently. But if there were a polynomial
solution for even a single NP-complete problem, then every
problem in NPC will be solvable in polynomial time. For this,
we need the concept of reductions.
Suppose there are two problems,A and B.
You know that it is impossible to solve problem A in
polynomial time.
You want to prove that B cannot be explained in polynomial
time.
We want to show that (A ∉ P) => (B ∉ P)
Definition: L is NP-complete if
1.L ϵ NP and
2.L' ≤ p L for some known NP-
complete problem L.'
NP-Complete Problems
Following are some NP-Complete problems,
for which no polynomial time algorithm is
known.
Determining whether a graph has a
Hamiltonian cycle
Determining whether a Boolean formula is
satisfiable, etc.
NP-Hard Problems
The following problems are NP-Hard
The circuit-satisfiability problem
Set Cover
Vertex Cover
Travelling Salesman Problem
DECISION PROBLEMS
n computability theory and computational complexity theory,
a decision problem is a problem that can be posed as
a yes-no question of the input values.
An example of a decision problem is deciding whether a
given natural number is prime.
CONCEPTS OF SAT
CIRCUIT SAT≤ρ SAT
SAT≤ρ CIRCUIT SAT
SAT ϵ NPC
CONCEPT: - A Boolean function is said to be SAT if the
output for the given value of the input is true/high/1.
SAT ϵ NPC: - As you know very well, you can get the SAT
through CIRCUIT SAT that comes from NP.
Proof:
Certificate – Let the certificate be a set S
consisting of nodes in the clique and S is a
subgraph of G.
Verification – We have to check if there exists a
clique of size k in the graph. Hence, verifying if
number of nodes in S equals k, takes O(1) time.
Verifying whether each vertex has an out-degree
of (k-1) takes O(k2) time.
(Since in a complete graph, each vertex is
connected to every other vertex through an
edge. Hence the total number of edges in a
complete graph = kC2 = k*(k-1)/2 ).
Therefore, to check if the graph formed by the k
nodes in S is complete or not, it takes O(k2) =
O(n2) time (since k<=n, where n is number of
vertices in G).
Therefore, the Clique Decision Problem has
polynomial time verifiability and hence belongs to
the NP Class.
The Clique Decision Problem belongs to NP-
Hard – A problem L belongs to NP-Hard if every NP
problem is reducible to L in polynomial time. Now, let
the Clique Decision Problem by C.
Consider the subgraph of G with the vertices <x2, 1>; <x1’, 2>; <x3,
3>. It forms a clique of size 3 (Depicted by dotted line in above
figure) .
U = {1,2,3,4,5}
S = {S1,S2,S3}
S1 = {4,1,3}, Cost(S1) = 5
S2 = {2,5}, Cost(S2) = 10
S3 = {1,4,3,2}, Cost(S3) = 3
There are two possible set covers {S1, S2} with cost 15
and {S2, S3} with cost 13.
2-Approximate Greedy Algorithm:
Let U be the universe of elements, {S1, S2,
… Sm} be collection of subsets of U and
Cost(S1), C(S2), … Cost(Sm) be costs of
subsets.
First Iteration:
I = {}
The per new element cost for S1 = Cost(S1)/|S1 – I| = 5/3
The per new element cost for S2 = Cost(S2)/|S2 – I| = 10/2
The per new element cost for S3 = Cost(S3)/|S3 – I| = 3/4
Second Iteration:
I = {1,4,3,2}
S1 = {1, 2}
S2 = {2, 3, 4, 5}
S3 = {6, 7, 8, 9, 10, 11, 12, 13}
S4 = {1, 3, 5, 7, 9, 11, 13}
S5 = {2, 4, 6, 8, 10, 12, 13}