Complexity Classes CSC 540 Christopher Siu 1 / 15 P Defjnition A - - PowerPoint PPT Presentation

complexity classes
SMART_READER_LITE
LIVE PREVIEW

Complexity Classes CSC 540 Christopher Siu 1 / 15 P Defjnition A - - PowerPoint PPT Presentation

Complexity Classes CSC 540 Christopher Siu 1 / 15 P Defjnition A complexity class is a set of languages decidable by a Turing machine within similar resource bounds. Practically, a complexity class is a set of problems of similar


slide-1
SLIDE 1

Complexity Classes

CSC 540 Christopher Siu

1 / 15

slide-2
SLIDE 2

P

Defjnition

A complexity class is a set of languages decidable by a Turing machine within similar resource bounds. Practically, a complexity class is a set of problems of similar computational (typically, time) complexity.

Defjnition

P is the class of languages decidable by a Turing machine in polynomial time. Practically, P is the class of problems that can be solved in polynomial time.

2 / 15

slide-3
SLIDE 3

NP

Defjnition

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. q0 > Non- deterministic “Guesser” Deterministic “Checker” qf

3 / 15

slide-4
SLIDE 4

NP-hard and NP-complete

Defjnition

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

Defjnition

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 effjciently checkable.

Example

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

4 / 15

slide-5
SLIDE 5

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 computers… …classes for space complexity…

Defjnition

A problem in P is often called tractable. An intractable problem might still be solvable, but the algorithm is probably not practical.

5 / 15

slide-6
SLIDE 6

Complexity Classes

all problems

NP P NP-complete NP-hard

6 / 15

slide-7
SLIDE 7

Reductions

Defjnition

A reduction 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 B f h Instance

  • f A

Solution to A No sol’n to A Algorithm for A

Instance

  • f B

Solution to B No solution to B

7 / 15

slide-8
SLIDE 8

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

slide-9
SLIDE 9

Maximum Element to Sorting

Magic Sort f h Unsorted sequence Maximum element n/a MaxElement

Unsorted sequence Sorted sequence n/a

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

9 / 15

slide-10
SLIDE 10

SAT to Clique

Defjnition

The boolean satisfjability problem, SAT, asks whether a proposition is satisifjable. This is typically restricted to propositions of n clauses in CNF, to eliminate trivial cases.

Defjnition

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

10 / 15

slide-11
SLIDE 11

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 ifg i = j and p ≡ ¬q. …the proposition is satisfjable ifg there exists a clique of n vertices.

Example

Given (p ∨ q ∨ r) ∧ (¬p ∨ r) ∧ (¬q ∨ ¬r): p1 q1 r1 ¬p2 r2 ¬r3 ¬q3

11 / 15

slide-12
SLIDE 12

Clique to Subgraph Isomorphism

Defjnition

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

slide-13
SLIDE 13

Karp’s Twenty-One Problems

In 1972, Richard Karp showed that 21 problems were NP-complete, including:

Satisfjability Integer programming Clique Set packing Vertex cover Hamiltonian cycle 3-SAT Graph coloring Knapsack Max cut

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

13 / 15

slide-14
SLIDE 14

P and NP

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

Example

Consider SAT, the boolean satisfjability 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 algorithms to solve NP-complete problems — we haven’t found them yet. If P = NP, then there exist NP-complete problems which we will never be able to solve in polynomial time.

14 / 15

slide-15
SLIDE 15

Questions?

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

15 / 15