You are on page 1of 16

APPROXIMAT

ION
ALGORITHM
S
/01
Introduction
and terminology
What are NP-
complete problems?
Are non deterministic polynomial time complex
problem ie we have solutions only with
exponential time complexity.

With small inputs: No problem.

We can check the answer in polynomial time.


Why to solve
them?
All the NP-complete optimization and
deterministic problems are important practical
problems. For ex. TSP, set covering problem,
subset sum etc.

If only one gets solved all the problem will get


solved.

Researches have showed probable 3D


conformations of protein is also a NP-complete
problem.
Approximation algorithms

We try to find algorithms which can give near optimal solutions in polynomial time called as
approximation algorithms.

The main work is to find the goodness of the near-optimal solution ie how close it is to perfect
solution.

Hence, complexity is defined in terms of approximation ratio/factor.


Approximation ratio

Ref. Cormen

The task for any approximation algorithm is to improve nearness of optimal solution by
decreasing value of approximation ratio.
/02
Vertex cover
problem
Problem statement

Vertex cover: a subset U of all vertices V, such that every edge E is covered

Covered Edge: If we choose a vertex all its edges come in the vertex cover set.

We want to find the set of minimum number of vertices such that we can cover all the edges.
Straightforward exponential
solution

We can make all the subset combinations starting from the empty set and increasing the size of
subset in each set and seeing if we cover all the edges or not. As we can check the answer in
polynomial time it won’t cause much problem.
N
Time complexity: O(2 )
Greedy approach

1. Sort the vertices on the basis of degrees


2. Choose the highest vertex in to the answer set
3. Remove all the edges coming from that vertex from the the graph
4. Check if all the edges are covered if no repeat from step 2

Choosing of different vertex when the degree is same gives different answer
Perfect solution for bipartite graph

In Graph theory, Konig’s theorem states that for a bipartite graph the problem of maximal
matching is equivalent to minimum vertex cover.

Maximal matching means a set of maximum edges such that no two edges share the same
vertex. If we take the endpoints of those edges we will get our solution.
/03
Important
techniques
Greedy approach

Dynamic Programming

Swarm intelligence

Simulated annealing

Random sampling
/04
Hashcode
problem
Greedy + Hill
climbing
First, we can create an order of tasks in
the most greedy way using basic sorting
for eg. p1,p2,p3,p4. Then we can do a
local search as for the swap of p2 and p4
if we get a positive reward we should
make it next near maxima and repeat the
step until we get as close to optimality.
<THANK
YOU>

You might also like