<<

Classes

CSC 540 Christopher Siu 1 / 15 P

Definition A is a of languages decidable by a within similar resource bounds.

Practically, a complexity class is a set of problems of similar computational (typically, time) complexity.

Definition P is the class of languages decidable by a Turing machine in time.

Practically, P is the class of problems that can be solved in polynomial time.

2 / 15 NP

Definition NP (“nondeterministic polynomial”) is the class of languages decidable by a nondeterministic Turing machine in polynomial time.

Practically, NP is the class of problems for which a solution can be checked in polynomial time.

Non- Deterministic > q0 deterministic qf “Checker” “Guesser”

3 / 15 NP-hard and NP-

Definition NP-hard is the class of problems at least as hard as every other problem in NP. Definition NP-complete is the class of problems in both NP and NP-hard.

In other words, NP-complete includes the hardest problems whose solutions are still efficiently checkable. Example

The Traveling Salesperson Problem is NP-hard. The decision version of TSP is NP-complete.

4 / 15 Other Complexity Classes

EXP is the class of problems solvable in exponential time. NEXP is the class of problems checkable in exponential time. …classes for probabilistic Turing machines… …classes for quantum … …classes for

Definition A problem in P is often called tractable.

An intractable problem might still be solvable, but the is probably not practical.

5 / 15 Complexity Classes

problems NP-hard

NP-complete

NP

P

6 / 15 Reductions

Definition A from a problem A to a problem B comprises: An algorithm f , transforms instances of A into those of B and An algorithm h, transforms solutions of B into those of A

Algorithm for A

Solution Solution h Instance Instance Algorithm to B to A f of A of B for B No sol’n No solution to B to A

7 / 15 Reductions

A reduction uses an algorithm for B to solve A. It is typically understood that the complexity of f and h is negligible compared to that of the algorithm for B.

Corollary If A can be reduced to B, then B is at least as hard as A.

If B was easier than A, the algorithm for B could be used to solve A, making A exactly as hard as B.

8 / 15 Maximum Element to Sorting

MaxElement

Sorted Maximum h Unsorted Unsorted Magic sequence element f sequence sequence n/a n/a

Where: f does nothing. MagicSort sorts the sequence in descending order. h returns the first element of the sequence.

9 / 15 SAT to

Definition The boolean satisfiability problem, SAT, asks whether a proposition is satisifiable.

This is typically restricted to propositions of n clauses in CNF, to eliminate trivial cases.

Definition The asks whether an undirected graph G contains a complete subgraph of n vertices.

10 / 15 SAT to Clique

Given a proposition of n clauses in CNF:

A vertex pi represents a variable p in clause i.

Two vertices pi, qj are adjacent iff i 6= j and p 6≡ ¬q. …the proposition is satisfiable iff there exists a clique of n vertices. Example Given (p ∨ q ∨ ) ∧ (¬p ∨ r) ∧ (¬q ∨ ¬r):

r1

q1 ¬p2

p1 r2

¬r3 ¬q3

11 / 15 Clique to Subgraph Isomorphism

Definition The subgraph isomorphism problem asks whether a graph G contains a subgraph isomorphic to another graph H.

This is a generalization of the clique problem.

The clique problem is equivalent to asking whether a graph G contains a subgraph isomorphic to Kn.

12 / 15 Karp’s Twenty-One Problems

In 1972, Richard Karp showed that 21 problems were NP-complete, including: Satisfiability Hamiltonian cycle 3-SAT Clique Set packing Knapsack Max cut

If any of these is solvable in polynomial time, they all are.

13 / 15 P and NP

The problems in NP-complete have solutions which can be checked efficiently but not found efficiently.

Example Consider SAT, the boolean satisfiability problem. A solution can be checked in polynomial time. A solution can be found in worst-case exponential time.

If P = NP, then there exist polynomial time to solve NP-complete problems — we haven’t found them yet.

If P 6= NP, then there exist NP-complete problems which we will never be able to solve in polynomial time.

14 / 15 Questions?

https://users.csc.calpoly.edu/~cesiu/csc540/slides/complexity.pdf

15 / 15