Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
ย
UNIT V.pptx
1. NP COMPLETE AND NP HARD
โข Np complete and np hard Computational Complexity Theory
โข Computational Complexity Theory is the study of how much of a
given resource (such as time, space, parallelism, algebraic operations,
communication) is required to solve important problems.
2. NP Completeness
โข Bad news:Huge number of fundamental problems have
defied classification for decades.
โข Some good news: Using the technique of reduction, we can
show that these fundamental problems are "computationally
equivalent" and appear to be different manifestations of one
really hard problem
3. 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
4. Optimization Problems
Ingredients:
Instances: The possible inputs to the problem.
Solutions for Instance: Each instance has an exponentially large set of
solutions.
Cost of Solution: Each solution has an easy to compute cost or value.
5. Non-Deterministic Poly-Time Decision
Problems (NP)
Key: Given
โขan instance I (= )
โขand a solution S (= subset of nodes)
โขthere is a poly-time alg Valid(I,S) to test whether or not S is a
valid solution for I.
โขPoly-time in |I| not in |S|.
6. Hamiltonian cycle problem
โข Consider the Hamiltonian cycle problem. Given an undirected graph G, does G
have a cycle that visits each vertex exactly once? There is no known polynomial
time algorithm for this dispute
Fig: Hamiltonian Cycle
Let us understand that a graph did have a Hamiltonian cycle. It would be easy for
someone to convince of this. They would similarly say: "the period is hv3, v7,
v1....v13i.
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.
8. 8
Knapsack Problem by DP
Given n items of
integer weights: w1 w2 โฆ wn
values: v1 v2 โฆ vn
a knapsack of integer capacity W
find most valuable subset of the items that fit into the
knapsack
11. 11
Knapsack Problem by DP
Given n items of
integer weights: w1 w2 โฆ wn
values: v1 v2 โฆ vn
a knapsack of integer capacity W
find most valuable subset of the items that fit into the
knapsack
Consider instance defined by first i items and capacity j (j ๏ฃ W).
Let V[i,j] be optimal value of such instance. Then
max {V[i-1,j], vi + V[i-1,j- wi]} if j- wi ๏ณ 0
V[i,j] =
V[i-1,j] if j- wi < 0
Initial conditions: V[0,j] = 0 and V[i,0] = 0