np completeness
play

NP Completeness Prof. Dr. Debora Weber-Wulff Winter term 2006/07 - PowerPoint PPT Presentation

NP Completeness Prof. Dr. Debora Weber-Wulff Winter term 2006/07 Inefficiency and Intractability From the book: Algorithmics, the Spirit of Computing, David Harel. Addison-Wesley, 1992 Complexity Paradox? Complicated algorithms often


  1. NP Completeness Prof. Dr. Debora Weber-Wulff Winter term 2006/07

  2. Inefficiency and Intractability • From the book: Algorithmics, the Spirit of Computing, David Harel. Addison-Wesley, 1992

  3. Complexity Paradox? • Complicated algorithms often have a lower complexity than the simple, obvious solutions • But we have fast computers, so who cares, anyway?

  4. Unfortunately,.... • There exist problems that cannot be solved in even quadratic time. • There are problems for which a solution just does not exist. • There are problems that also need exponential space!

  5. Towers of Hanoi • What was the complexity? 2 N -1

  6. Towers of Hanoi • Even moving a million rings a second, for 64 rings you need half a million years to complete the puzzle. • If you need 10 sec / ring, you need five trillion years! • This is provably the lower bound.

  7. Decision problems • Don't do anything but answer "yes" or "no" • Purpose is to decide if a property holds for the input

  8. The Monkey Puzzle • Can 9 of these be laid in a 3x3?

  9. General Problem • Given N cards, N= M*M, each edge decorated with an upper or lower half of a figure. • Can the cards be laid out in an M*M pattern so that the figures of adjoining cards match?

  10. Brute Force • For all possible cards and all possible orientations of the cards, lay them out in M*M • Return "yes" if this is a valid layout, otherwise continue • When all cases have been tested, return "no".

  11. Complexity? • Disregarding the orientation: O(N!) • With the orientation: O(4*N!) which is still O (N!) • O(9) = 362 800, O(4*9) = 1 451 520

  12. That's not so bad • But what about N=25? • 25! is a number with 26 digits, if you could test a million arrangements a second, you would need over 490 billion years to check it!

  13. Isn't there a clever solution? • You can stop as soon as you find that the pattern is illegal • This does not really change the complexity. • There is no known way to solve this problem in Polynomial time

  14. Reasonable vs. Unreasonable Time • Factorial grows faster than exponential, even though N 1000 is still greater than N! for many values of N. • For example at N=1165, the factorial oversteps the exponential function.

  15. Good vs. Bad functions • Good functions run in Polynomial time: N k + c 1 *N k-1 + .... + c k-1 • We say they have an upper bound of N k • Everything else is superpolynomial

  16. Superpolynomial • logarithmic, linear, quadratic, cubic – all are polynomial • 1.001 N + N 6 , 5 N , N N , N! are exponential or worse • N log N are superpolynomial but not 2 exponential

  17. Growth rates

  18. Tractable • Problems that are solvable in polynomial time are called tractable • Problems that are solvable in superpolynomial time are called intractable

  19. Intractable Problems • Need impractically large amounts of time even on relatively small inputs • And there are lots of them.... close to 1000 different problems.

  20. Proof? • Even worse, we have not been able to prove that no polynomial solution exists! • We just don't know! • This class of problems is called NPC, NP-complete problems, and it is growing

  21. NP-Complete • Strangely enough, have a linear lower bound, but an exponential upper bound.

  22. NP-Complete problems • Two-dimensional Arrangment • Path-finding (TSP) • Scheduling and Matching • Determining Logical Truth • Coloring Maps and Graphs

  23. Short Certificates • Even though they are difficult to find, once we have a solution "yes", we can easily prove that it solves the problem. • We call this the short certificate or magic coin

  24. Short Certificates • are often linear • For example, it is hard to find a Hamiltonian path, but easy to test that it is indeed one.

  25. Magic Coin • We begin with a partial solution and extend it. • If we could flip a magic coin to determine whether the next step leads to a yes or no, we could win • This is called non-determinism

  26. NPC • Non-deterministic Polynomial are those problems which are intractable, but have a non- deterministic polynomial certificate • C stands for Complete

  27. Completeness • NPC problems are those which can be solved if we find a polynomial solution for even one!! • Either all NPC problems are tractable, or they are all intractable, but we just don't know!

  28. Polynomial-time Reduction • It is possible in Polynomial time to reduce one NPC-Problem to another one. • TSP can be formulated as Hamiltonian Path.

  29. P = NP? • This is one of the big research questions! • Open since it was posed in 1971

  30. Testing for Primeness • Is a number not prime? • If the answer is yes, we deliver a short certificate, the two factors, which can be readily multiplied • So this is NP, but we do not know if it is NP complete, or even P!

  31. Testing for Primeness • Is this number prime? • No short certificate, so not obvious, that it is in NP (but this has since been proven) • But we do not know if this is NP- complete or not!!!

  32. Intractable and not NPC • Towers of Hanoi • Roadblock • Satisfiablity – reasoning about propositional calculus

  33. Can it get worse? • Of course – double or triple exponential! • Satisfiability in Presburger Arithmetic

  34. Complexity Classes

  35. Imperfect Solutions • Sometimes we are happy with a solution that is not optimal – an approximation • Often heuristic (rule of thumb) methods yield good results, for example with TSP.

  36. No amount of cleverness can help when your problem is NP!

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend