Download presentation

Presentation is loading. Please wait.

Published byDevin Silverthorn Modified over 4 years ago

1
CS211 Problems: unsolvable, unfeasible and unsolved Topic 3: P and NP

2
3 topics 1.Turing machines – as a definition of computable 2. An uncomputable problem and 3.Problems that take so long they might as well be – which leads to an unsolved (not the same as uncomputable) problem in computer science This problem is still open

3
Better Machines vs. Better Algorithms New machine. Costs $$$ or more. Makes "everything" finish sooner. Incremental quantitative improvements (Moore's Law). May not help much with some problems. New algorithm. Costs $ or less. Dramatic qualitative improvements possible! (million times faster) May make the difference in allowing solution at all May not help much with some problems.

4
P – a category of algorithms Relatively Efficient: polynomial time for ALL inputs. - mergesort requires N logN steps Inefficient: "exponential time" for SOME inputs. - brute force TSP takes N! steps (TSP coming up) P is the set of all DECISION problems that are solvable in POLYNOMIAL TIME on a DETERMINISTIC Turing machine. (decision problems are problems reduced to yes/no) (For instance, CAN you sort these numbers? YES or NO) (best thing to do is just sort them)

5
What is the story on non- polynomial time?

6
It takes how long????

7
Examples of P (lots of them) MULTIPLE: Is the integer y a multiple of x? YES: (x, y) = (17, 51). NO: (x, y) = (17, 50). O(1) SORT: Can you sort these n numbers? The answer is always yes – just do it O(n logn)

8
Apparent Counter-Examples Travelling Sales Person (TSP): Given all the N state capitals, can you find a route through them that costs < some amount would have to try all N! possibilities - O(N!) Satisfiability (SAT): Is there a way to assign values to a boolean expression in N variables that makes it true? P && Q is true when P is true and Q is true But you would have to try all combinations - O(2 N ) (but can we be sure there isn’t a better algorithm??)

9
NP – another category of algorithms NP: does NOT mean "not polynomial.“ NP: set of all decision problems with polynomial CERTIFICATION (ie checking) algorithm. Equivalent definition NP: set of all decision problems solvable in polynomial time on a NONDETERMINISTIC (ie lucky) Turing machine.

10
Certifier: check whether a proposed "solution" is correct. –proposed solution is called CERTIFICATE –certificate must be of polynomial size

11
Examples Consider the TSP If I give you a path you can check in O(N) whether it costs less than $$$ Consider SAT If I give you a solution you can check it - decide if the expression is true in O(N) again

12
Other definition uses non-determinism That means that at every stage TM can guess the best solution. So, TSP: pick a town (lucky), pick another etc – O(N) Sorting: go through the list place each element in the ‘right’ place – O(N) You can actually do this on a TM but have to simulate parallelism which is exponential

13
Obviously P NP Is P = NP? THIS IS UNSOLVED! Unlikely but no one has every proved it Huge prize available!

14
NP complete-ness A problem in NP with the property that if it can be solved efficiently, then it can be used as a subroutine to solve any other problem in NP efficiently. "Hardest computational problems" in NP. If any NP complete problem is in P - then they ALL are

15
Some problems are NP complete TSP SAT

16
Some problems it is still unknown whether they are NP complete See Integer factorization http://en.wikipedia.org/wiki/Prime_factorization decomposition of an integer into its prime divisors (for instance 24 is 2x2x2x3) When the numbers are very large, no efficient algorithm is known. There is an obvious slow algorithm, just start dividing by the primes 2,3,5, etc. An algorithm which efficiently factors any integer would render RSA-based public-key cryptography insecure (Rivest, Shamir and Adleman – MIT 1970s).RSA

17
Some problems were thought to be NP and then turned out not to be See Linear Programming http://www.quora.com/What-problems-were- once-thought-not-to-be-solvable-in-polynomial- time-but-eventually-were But they weren’t NP complete problems of course

18
Coping with P, NP, and NP completeness Make up a pretty good approximation algorithm Assume the worst case doesn’t occur (you have to work at it to make TSP where you just go to cheapest place next, not an OK algorithm) Keep trying to show P=NP But don’t look like an idiot by not recognising them! Insert story here

19
So, what has been ‘the point’ of all this? The general idea of a machine with states, transitions and an infinite tape Explaining the idea that a Turing machine can compute anything that is computable - actual machines are irrelevant The notion that there are things that aren't computable (halting problem is the obvious one) The idea that some algorithms are fine in theory but not in practice That there exist open problems in Computer Science It’s all Mark Neal’s fault: I just don't want them to look stupid when the topic of computability comes up at a cocktail party Insert story here ; )

Similar presentations

OK

Computational Complexity Polynomial time O(n k ) input size n, k constant Tractable problems solvable in polynomial time(Opposite Intractable) Ex: sorting,

Computational Complexity Polynomial time O(n k ) input size n, k constant Tractable problems solvable in polynomial time(Opposite Intractable) Ex: sorting,

© 2018 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google