You are on page 1of 11

CS 306: DAA, IIITDM Jabalpur

11/10/2012

NP-Complete Problems - II

Search vs. Optimization Problems


We say that all NP problems are search problems But, some problems are optimization problems (As we know them from the beginning)
Ex: TSP, in which the shortest possible tour is sought

Can we express TSP as a search problem?


Yes: We are asked to find a tour, that passes through every vertex exactly once and of total cost b or less, or to report that no such tour exists

But, then why dress it up as something else?

CS 306: DAA, IIITDM Jabalpur

11/10/2012

Search vs. Optimization Problems


For one good reason
to compare and relate problems It allows us to deal with both kinds of problems, exactly same way!

Search vs. Optimization Problems


Claim: Turning an optimization problem into a search problem does not change its difficulty at all
Forward Argument - Any algorithm that solves the optimization TSP also readily solves the search problem Reverse Argument - suppose we knew the cost of the optimum tour; then we could find this tour by calling the algorithm for the search problem, using the optimum cost as the budget How to find the optimum cost? by Binary Search

CS 306: DAA, IIITDM Jabalpur

11/10/2012

Search vs. Optimization Problems


Optimization Problem to Search Problem
Q: Why to introduce a budget b here? Ans: Solution to the search should be easily verifiable (in P time, remember ?). How could one check the property is op=mal?

TSP vs. MST


TSP - given a distance matrix and a bound b, and are asked to find a tree T with total weight where dij is sequentially computed MST - given a distance matrix and a bound b, and are asked to find a tree T with total weight

CS 306: DAA, IIITDM Jabalpur

11/10/2012

Independent Set
Problem - A subset of nodes S V is an independent set of graph G = (V, E) if there are no edges between them An Example:
{1, 5} is an independent set {1, 4, 5} - ? {2, 3, 6} - ?

Independent Set in Trees


A DP Solution Sub Problems ?
Lets I(u) - the size of largest independent set of sub-tree hanging from u: Express I(u) in terms of say, I(w) Ans: I(r), r being the root node

CS 306: DAA, IIITDM Jabalpur

11/10/2012

Vertex Cover
A Vertex Cover of a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set The problem of finding a Minimum Vertex Cover is a classical optimization problem in algorithms

Clique
A Clique in an undirected graph is a subset of its vertices such that every two vertices in the subset are connected by an edge finding whether there is a clique of a given size in a graph (the Clique problem) is NPcomplete

CS 306: DAA, IIITDM Jabalpur

11/10/2012

Clique
A graph with 23 1-vertex cliques (its vertices), 42 2-vertex cliques (its edges), 19 3-vertex cliques (the light blue triangles), and 2 4-vertex cliques (dark blue). the clique number of the graph is 4

Reduction
A B (A is Polynomial Time Reducible to B)
Efficient Problems: If B is efficient then A is also efficient Hard Search Problems (NP Complete): If A is hard then B is also hard

So if A is NP-complete,
a new search problem B is also NP-complete, simply by reducing A to B This is how the set of NP-Complete problems has grown since then

CS 306: DAA, IIITDM Jabalpur

11/10/2012

RUDRATA PATH

RUDRATA CYCLE

RUDRATA (s, t) PATH RUDRATA CYCLE ? RUDRATA CYCLE problem: given a graph, is there a cycle that passes through each vertex exactly once? RUDRATA (s, t)- PATH problem: given a graph with two vertices s and t, and we want a path starting at s and ending at t that goes through each vertex exactly once

RUDRATA PATH

RUDRATA CYCLE

CS 306: DAA, IIITDM Jabalpur

11/10/2012

RUDRATA PATH

RUDRATA CYCLE

We have to consider both the cases


When the instance of RUDRATA CYCLE has a solution When the instance of RUDRATA CYCLE does not have a solution

Class NP-C: Some Other Examples


Composite Numbers Determining whether a number can be written as the product of two other numbers is the composite numbers problem. If a solution is found, it is simple to verify it, but no efficient method of finding the solution exists. Assignment Assignment of compatible room-mates: assume we have a number of students to be assigned to rooms in a college. They can be represented as the vertices on a graph with edges linking compatible pairs. If we have two per room, a class P algorithm exists, but if three are to be fitted in a room, we have a class NP problem.

CS 306: DAA, IIITDM Jabalpur

11/10/2012

Graph Coloring
Map Coloring
The three-colour map colouring problem asks if we can colour a map so that no adjoining countries have the same colour. Once a solution has been guessed, then it is readily proved This problem is easily answered if there are only 2 colours - there must be no point at which an odd number of countries meet - or 4 colours - there is a proof that 4 colours suffice for any map This problem has a graph equivalent: each vertex represents a country and an edge is drawn between two vertices if they share a common border. Its solution has a more general application. If we are scheduling work in a factory: each vertex can represent a task to be performed - they are linked by an edge if they share a common resource, eg require a particular machine. A colouring of the vertices with 3 colours then provides a 3-shift schedule for the factory.

Reduction Again!
Many problems are reducible to others:
Map colouring can be reduced to graph colouring. A solution to a graph colouring problem is effectively a solution to the equivalent map colouring or scheduling problem. The map or graph-colouring problem may be reduced to the boolean satisfiability problem. To give an informal description of this process, assume the three colours are red, blue and green. Denote the partial solution, "A is red" by ar so that we have a set of boolean variables:

CS 306: DAA, IIITDM Jabalpur

11/10/2012

Reduceability
ar ab ag br Now a solution to the problem may be found by finding values for ar, ab, etc which make the expression true: ((ar and not ab and not ag) and ( (bb and (cb and (dg .... bb bg cr ... A is red A is blue A is green B is red B is blue B is green C is red ...

Reduceability
Thus solving the map colouring problem is equivalent to finding an assignment to the variables which results in a true value for the expression - the Boolean Satisfiability problem

10

CS 306: DAA, IIITDM Jabalpur

11/10/2012

References
Chapter 8, Algorithms by S. Dasgupta, C.H. Papadimitriou, and U.V. Vazirani

11

You might also like