Docsity

NP-complete Problem - Data Structures - Lecture Slides, Slides of Data Structures and Algorithms

Partial preview of the text

Download NP-complete Problem - Data Structures - Lecture Slides and more Slides Data Structures and Algorithms in PDF only on Docsity!

NP-complete Problem

Decision Problems

To keep things simple, we will mainly concern ourselves with decision problems. These problems only require a single bit output: yes'' andno''.

How would you solve the following decision problems?

Is this directed graph acyclic? Is there a spanning tree of this undirected graph with total weight less than w? Does this bipartite graph have a perfect (all nodes matched) matching? Does the pattern p appear as a substring in text t?

Nice Puzzle

The class NP (meaning non-deterministic polynomial time) is the set of problems that might appear in a puzzle magazine: ``Nice puzzle.''

What makes these problems special is that they might be hard to solve, but a short answer can always be printed in the back, and it is easy to see that the answer is correct once you see it.

Example... Does matrix A have an LU decomposition?

No guarantee if answer is ``no''.

Good Guessing

Another way of thinking of NP is it is the set of problems that can solved efficiently by a really good guesser.

The guesser essentially picks the accepting certificate out of the air (Non-deterministic Polynomial time). It can then convince itself that it is correct using a polynomial time algorithm. (Like a right-brain, left-brain sort of thing.)

Clearly this isn't a practically useful characterization: how could we build such a machine?

Exponential Upperbound

Another useful property of the class NP is that all NP problems can be solved in exponential time (EXP).

This is because we can always list out all short certificates in exponential time and check all O(2nk) of them.

Thus, P is in NP, and NP is in EXP. Although we know that P is not equal to EXP, it is possible that NP = P, or EXP, or neither. Frustrating!

HARD AND EASY PROBLEMS

(a very informal introduction) Good starting points for precise definitions and formal introduction are Papadimitriou: Computational Complexity , Adison-Wesley, 1994 Garey and Johnson: Computers and Intractability , Freeman 1979 Schrijver: Theory of Linear and Integer Programming , Wiley, 1986, (Chapter 2)

P : Collection Z of problems is in P (polynomial-time solvable) if there exists a polynomial-time algorithm that solves any problem in Z, i.e, the algorithm that requires at most f(s) basic steps where s =size of the input and f is a polynomial.

NP: Collection Z of decision problems is in NP (nondeterministic polynomial- time solvable) if there exists a polynomial time algorithm to check the correctness of the YES answer.

co-NP: replace YES by NO in the above definition.