Presentation is loading. Please wait.

Presentation is loading. Please wait.

P, NP, and Exponential Problems Should have had all this in CS 252 – Quick review Many problems have an exponential number of possibilities and we can.

Similar presentations


Presentation on theme: "P, NP, and Exponential Problems Should have had all this in CS 252 – Quick review Many problems have an exponential number of possibilities and we can."— Presentation transcript:

1 P, NP, and Exponential Problems Should have had all this in CS 252 – Quick review Many problems have an exponential number of possibilities and we can try each option against some objective to get an answer – Note that this "testing" is fast (always polynomial!) This approach is intractable In many cases (Edit distance, longest increasing subsequence, etc.) we have been able to use smart algorithms (Greedy, DP, LP) to search a small subset of the exponential possibilities and get optimal solutions in polynomial time In other tasks (TSP, ILP) there are no known polynomial solutions CS 312 – NP Problems1

2 NP vs P Examples For the problems in P we were able to find diverse algorithmic approaches to solve them efficiently with different complexities, but all within P There is a consistency amongst the problems in NP which make them all equally hard to solve CS 312 – NP Problems2

3 Tasks as Search Problems We can consider all these tasks as search problems Given an instance I of the problem, can we find a solution S to I, or state that no solutions exists – I could be a CNF equation for 3SAT and S would be a particular variable setting For NP search problems we have an efficient mechanism, C(I,S) which checks to see if a particular variable setting S is a solution to I We would also like an efficient verification approach for optimization problems (like TSP) We recast as: For an instance I does there exists an S ≤ b – For TSP I would be a city distribution, S a path, and b an arbitrary distance – This is still an NP problem for arbitrary b – Now, for any particular path S we can quickly answer the question of whether S ≤ b (i.e. C(I,S)) – How could we find the optimal solution with this recasting? CS 312 – NP Problems3

4 P –Polynomial Time Now we have the basis of a consistent search algorithm Try each case and test it (i.e. see if it solves the problem or calculate what value it gives for doing optimization) If we have a deterministic algorithm which can make the decision by only checking a polynomial number of possibilities, then the task is in P (polynomial time) P = Those problems which can be decided in polynomial time Problems in P are efficient CS 312 – NP Problems4

5 NP – Non-Deterministic Polynomial Time If not in P then task is in NP (Non-Deterministic Polynomial Time) or worse – Class NP are those problems that can be solved in polynomial time on a non-deterministic machine Remember that a non-deterministic machine basically tries all alternatives in parallel, with the time complexity being equal to the longest path (always polynomial length) in the potentially exponentially wide search tree – Thus, the class NP are those problems that can be tested/verified in polynomial time Deterministic implementations of non-deterministic machines require checking all possible solutions leading to exponential time complexity CS 312 – NP Problems5

6 P P = problems that can be solved in polynomial time on a deterministic Turing Machine.

7 P, NP P = problems that can be solved in polynomial time on a deterministic Turing Machine. NP = problems that can be solved in polynomial time on a non-deterministic Turing machine P  NP, because every problem in P has a solution in NP

8 Reductions Again As long as f and h are polynomial time translations (have complexity ≤ B) then algorithm A will have the same complexity as algorithm B We say A reduces to B A search problem is NP-Complete if all other search problems in NP reduce to it CS 312 – NP Problems8

9 NP-Completeness Thus if we can find a polynomial time solution to any of the NP-complete problems, then we can solve all of them in polynomial time, and then P = NP CS 312 – NP Problems9

10 Unsolvable Problems There are problems in higher complexity classes than NP – Guaranteed exponential, super-exponential, etc. – List all possible paths in a TSP problem – List the power-set of all possible paths in TSP, etc. There is an even larger infinite class of unsolvable problems regardless of time available – For any arbitrary polynomial equation in many variables e.g.: – x 2 yz 3 + 3y 2 z – 4xy 5 z 2 = 7 – Are there integer values of the variables which solve it? (x, y, and z in this case) Problems as Functions – Regularity vs Random – Also many regular problems that are not solvable: halting, etc. CS 312 – NP Problems10


Download ppt "P, NP, and Exponential Problems Should have had all this in CS 252 – Quick review Many problems have an exponential number of possibilities and we can."

Similar presentations


Ads by Google