Docsity

NP-complete Problems Three - Data Structures - Lecture Slides, Slides of Data Structures and Algorithms

Partial preview of the text

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

NP-complete Problems

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?

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! NP-hardness

As we will see, some problems are at least as hard to solve as any problem in NP. We call such problems NP-hard.

How might we argue that problem X is at least as hard (to within a polynomial factor) as problem Y? Docsity.com

Cook's Theorem

The Satisfiability problem

x = ((A+B)C)((ABC')+C)(ABC')

Can you assign boolean (true or false) values to each of A, B, and C so that x is true?

If so, we say that the circuit is 'satisfiable.'

This circuit (which could also be drawn with AND/OR/NOT gates) is unsatisfiable. (Make sure you review how to draw an AND/OR/NOT circuit from a boolean equation. You've usually seen the equations written with x, y, and z instead of A, B, and C.)