Unit 5 Tractable and Intractable Problems
Unit 5 Tractable and Intractable Problems
in
DAA
Unit-5
Computability Vs Complexity
fi
problem.
5.3 NP-class
● The problem belongs to NP, if it’s easy to check a solution that may
have been very tedious to nd.
fi
● It solves the problem which is veri able by polynomial time.
fi
● It is a class of decision problems.
● Hence it is used to verify the solution is correct, not for nding the
fi
● If there is a problem in this class then it can be solved by exhaustive
search in exponential time.
5.4 NP-complete
Hamiltonian cycles
Optimal graph coloring
Travelling salesman problem
Finding the longest path in graph, etc
Clique
● But the brute force search is too time consuming for a network
which has more than a few dozen vertices present in the graph.
Example:
fi
vertex cover.
{(1,6),(1,2),(1,4),(2,3),(2,4),(6,7),(4,7),(7,8),(3,8),(3,5),(8,5)}
Eliminate all the edges, which are either incident to vertex 1 or 6 and we
add edge (1, 6) to cover.
5.5 NP-hard
Theorem-1
Theorem-2
The following sets are P-reducible to each other in pairs (and hence
each has the same polynomial degree of di culty): {tautologies}, {DNF
ffi
tautologies}, D3, {sub-graph pairs}.
Theorem-3
Theorem-4
ffi
satisfaction.
● Fourth, Cook suggested that NP's other issues could share this
property of being the hardest member of NP with the satisfaction issue.
fi
any problem-instance.
Reduction
If the NPC problem solution does not exist, then within the polynomial
era, the conversion from one NPC problem to another NPC problem.
You need the de nition of reduction for this. If within the polynomial
fi
time there is a solution to the one NPC problem, then the rest of the
problem may also give the polynomial time solution (but it is di cult
ffi
to believe). You need the de nition of reduction for this.
fi
Example :
There are two questions, A and B, suppose. You know that solving
problem A in polynomial time is di cult. You want to show that, in
ffi
polynomial time, B can not be solved. Thus, in polynomial time, you
can transform problem A into problem B.
fi
travelling salesperson problem, and the approximation issue is to nd
fi
a short cycle.
fi
the vertex cover with the fewest vertices, and the approximation
problem is nding the vertex cover with the fewest vertices.
fi
An algorithm A is said to be an algorithm, given an optimization
problem P.
Types of Approximation
P An optimization problem
A An approximation algorithm
I An instance of P
Absolute Approximation
● Vertex cover
Example :
1. Vertex Cover
3. Bin Packing
Key takeaway :
fi
whereas randomized algorithms like Las Vegas are dependent on the
value of random variables and hence in these algorithms worst case
identi cation becomes tougher.
fi
In order to compute expected time taken in the worst case an time
taken by every possible value needs to be evaluated. Average of all
evaluated times is the expected worst case time complexity
for
{
x=2* rand.Float64()-1
y=2* rand.Float64()-1
if x*x+y*y < 1
Return
If a point(x, y) with -1< x <1 and -1<y <1 are placed randomly then the
ratio of points that fall within the unit circle will be close to .
const a = 99999
count := 0
y := 2*rand.Float64() - 1
if x*x+y*y < 1 {
count++
Key takeaway :
References:
Reading, MA.
Viewed using Just Read