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 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
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. Non- deterministic “Guesser” Deterministic “Checker” q f 3 / 15 > q 0
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
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
Complexity Classes all problems NP P NP-complete NP-hard 6 / 15
Reductions Solution No solution to B to B Solution of B Instance Algorithm for A to A No sol’n to A of A Defjnition Instance h f for B Algorithm An algorithm h , transforms solutions of B into those of A and An algorithm f , transforms instances of A into those of B A reduction from a problem A to a problem B comprises: 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 Unsorted h returns the fjrst element of the sequence. MagicSort sorts the sequence in descending order. f does nothing. Where: n/a sequence Sorted sequence MaxElement Magic n/a element Maximum sequence Unsorted h f Sort 9 / 15
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
SAT to Clique Given a proposition of n clauses in CNF: …the proposition is satisfjable ifg there exists a clique of n vertices. Example 11 / 15 A vertex p i represents a variable p in clause i . Two vertices p i , q j are adjacent ifg i � = j and p �≡ ¬ q . Given ( p ∨ q ∨ r ) ∧ ( ¬ p ∨ r ) ∧ ( ¬ q ∨ ¬ r ) : r 1 ¬ p 2 q 1 p 1 r 2 ¬ r 3 ¬ q 3
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 K n . 12 / 15
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
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. NP-complete problems — we haven’t found them yet. will never be able to solve in polynomial time. 14 / 15 If P = NP, then there exist polynomial time algorithms to solve If P � = NP, then there exist NP-complete problems which we
Questions? https://users.csc.calpoly.edu/~cesiu/csc540/slides/complexity.pdf 15 / 15
Recommend
More recommend