1 Tractability u Some problems are intractable as
1
Tractability u Some problems are intractable: as they grow large, we are unable to solve them in reasonable time u What constitutes reasonable time? » Standard working definition: polynomial time » On an input of size n the worst-case running time is O(nk) for some constant k » O(n 2), O(n 3), O(1), O(n lg n), O(2 n), O(n!) » Polynomial time: O(n 2), O(n 3), O(1), O(n lg n) » Not in polynomial time: O(2 n), O(n!) 2
Polynomial-Time Algorithms u Are some problems solvable in polynomial time? » Of course: many algorithms we’ve studied provide polynomial-time solutions to some problems u Are all problems solvable in polynomial time? » No: Turing’s “Halting Problem” is not solvable by any computer, no matter how much time is given u Most problems that do not yield polynomial-time algorithms are either optimization or decision problems. 3
Optimization/Decision Problems u Optimization Problems: » An optimization problem is one which asks, “What is the optimal solution to problem X? ” » Examples: v 0 -1 Knapsack v Fractional Knapsack v Minimum Spanning Tree u Decision Problems » An decision problem is one with yes/no answer » Examples: v Does a graph G have a MST of weight W? 4
Optimization/Decision Problems u u u An optimization problem tries to find an optimal solution A decision problem tries to answer a yes/no question Many problems will have decision and optimization versions. » Eg: Traveling salesman problem v optimization: find hamiltonian cycle of minimum weight v decision: is there a hamiltonian cycle of weight k u Some problems are decidable, but intractable: as they grow large, we are unable to solve them in reasonable time » Is there a polynomial-time algorithm that solves the problem? 5
Non-deterministic polynomial time u Deterministic Polynomial Time: The TM takes at most O(nc) steps to accept a string of length n u Non-deterministic Polynomial Time: The TM takes at most O(nc) steps on each computation path to accept a string of length n 6
The Class P P: the class of decision problems that have polynomial-time deterministic algorithms. » That is, they are solvable in O(p(n)), where p(n) is a polynomial on n » A deterministic algorithm is (essentially) one that always computes the correct answer Why polynomial? » if not, very inefficient » nice closure properties v the sum and composition of two polynomials are always polynomials too 7
Complexity Class P u Deterministic in nature u Solved by conventional computers in polynomial time » » » O(1) O(log n) O(n 2) u Polynomial Constant Sub-linear Linear Nearly Linear Quadratic upper and lower bounds 8
Sample Problems in P u Fractional Knapsack u MST u Sorting u Others? 9
The class NP NP: the class of decision problems that are solvable in polynomial time on a nondeterministic machine (or with a nondeterministic algorithm) u (A determinstic computer is what we know) u A nondeterministic computer is one that can “guess” the right answer or solution » Think of a nondeterministic computer as a parallel machine that can freely spawn an infinite number of processes u Thus NP can also be thought of as the class of problems » whose solutions can be verified in polynomial time; or » that can be solved in polynomial time on a machine that can pursue infinitely many paths of the computation in parallel u Note that NP stands for “Nondeterministic Polynomial-time” 10
Complexity Class NP u u Non-deterministic part as well choose(b): choose a bit in a non-deterministic way and assign to b If someone tells us the solution to a problem, we can verify it in polynomial time Two Properties: non-deterministic method to generate possible solutions, deterministic method to verify in polynomial time that the solution is correct. 11
Sample Problems in NP u Fractional Knapsack u MST u Sorting u Others? » Hamiltonian Cycle (Traveling Salesman) » Graph Coloring » Satisfiability (SAT) v the problem of deciding whether a given Boolean formula is satisfiable 12
Review: P And NP Summary u. P = set of problems that can be solved in polynomial time » Examples: Fractional Knapsack, … u NP = set of problems for which a solution can be verified in polynomial time » Examples: Fractional Knapsack, …, Hamiltonian Cycle, CNF SAT, 3 -CNF SAT P NP u Open question: Does P = NP? u Clearly » Most suspect not » An August 2010 claim of proof that P ≠ NP, by Vinay Deolalikar, researcher at HP Labs, Palo Alto, has flaws 13
NP-complete problems u A decision problem D is NP-complete iff 1. D NP 2. every problem in NP is polynomial-time reducible to D u u TSP is NP HC is NP-complete 14
Reduction u. A problem R can be reduced to another problem Q if any instance of R can be rephrased to an instance of Q, the solution to which provides a solution to the instance of R » This rephrasing is called a transformation u Intuitively: If R reduces in polynomial time to Q, R is “no harder to solve” than Q u Example: lcm(m, n) = m * n / gcd(m, n), lcm(m, n) problem is reduced to gcd(m, n) problem 15
Some NP-Complete Problems u Six basic genres of NP-complete problems and paradigmatic examples. » » » Packing problems: SET-PACKING, INDEPENDENT SET. Covering problems: SET-COVER, VERTEX-COVER. Constraint satisfaction problems: SAT, 3 -SAT. Sequencing problems: HAMILTONIAN-CYCLE, TSP. Partitioning problems: 3 D-MATCHING 3 -COLOR. Numerical problems: SUBSET-SUM, KNAPSACK. 16
NP-Complete Set NP-Complete NP P 17
- Slides: 17