an overview of computational complexity
play

An Overview of Computational Complexity - PowerPoint PPT Presentation

An Overview of Computational Complexity kazim@fouladi.ir


  1. مهدراهچ‌لصف يتابساحم‌يگديچيپ‌رب‌يرورم An Overview of Computational Complexity يدلبوف‌مظاك kazim@fouladi.ir رتويپماك‌و‌قرب‌يسدنهم‌ي‌هدكشناد نارهت‌هاگشناد رتويپماك‌و‌قرب‌يسدنهم‌ي‌هدكشناداه‌نيشام‌و‌اه‌نابز‌ي‌هيرظن

  2. Computational Complexity 2

  3. Time Complexity: The number of steps during a computation Space used Space Complexity: during a computation 3

  4. Time Complexity • We use a multitape Turing machine • We count the number of steps until a string is accepted • We use the O(k) notation 4

  5. Example:  n n  { : 0 } L a b n Algorithm to accept a string : w • Use a two-tape Turing machine • Copy the on the second tape a • Compare the and a b 5

  6.  n n  { : 0 } L a b n Time needed: • Copy the on the second tape (| w |) O a • Compare the and a b (| w |) O Total time: (| w |) O 6

  7.  n n  { : 0 } L a b n For string of length n time needed for acceptance: ( n ) O 7

  8. Language class: ( n ) DTIME ( n ) DTIME L 1 L 3 L 2 A Deterministic Turing Machine accepts each string of length n in time ( n ) O 8

  9. ( n ) DTIME n n  { : 0 } a b n { ww } 9

  10. In a similar way we define the class ( ( )) DTIME T n for any time function: ( n ) T 2 3 Examples: ( ), ( ),... DTIME n DTIME n 10

  11. Example: The membership problem for context free languages L  { : is generated by grammar } w w G ( 3 L  (CYK - algorithm) ) DTIME n Polynomial time 11

  12. k k 1 Theorem: DTIME n ( ) DTIME n ( )  1 k ( ) DTIME n ( k ) DTIME n 12

  13. Polynomial time algorithms: ( k ) DTIME n Represent tractable algorithms: For small we can compute the k result fast 13

  14. The class P   ( k for all k ) P DTIME n • Polynomial time • All tractable problems 14

  15. P CYK-algorithm n b n { } a  { ww } 15

  16. Exponential time algorithms: ( n 2 ) DTIME Represent intractable algorithms: Some problem instances may take centuries to solve 16

  17. Example: the Traveling Salesperson Problem 5 3 1 2 4 2 6 10 8 3 Question: what is the shortest route that connects all cities? 17

  18. 5 3 1 2 4 2 6 10 8 3 Question: what is the shortest route that connects all cities? 18

  19. Example: the Hamiltonian Problem s t Question: is there a Hamiltonian path from s to t? 19

  20. s t YES! 20

  21. A solution: search exhaustively all paths L = {<G,s,t>: there is a Hamiltonian path in G from s to t} n   ( ! ) ( 2 ) L DTIME n DTIME Exponential time Intractable problem 21

  22. Example: The Satisfiability Problem Boolean expressions in Conjunctive Normal Form:      t t t t 1 2 3 k       t x x x x 1 2 3 i p Variables Question: is expression satisfiable? 22

  23. Example:    ( ) ( ) x x x x 1 2 1 3 Satisfiable:    0 , 1 , 1 x x x 1 2 3     ( ) ( ) 1 x x x x 1 2 1 3 23

  24.    Example: ( ) x x x x 1 2 1 2 Not satisfiable 24

  25. L  { : expression is satisfiabl e} w w For variables: L  ( n n 2 ) DTIME exponential Algorithm: search exhaustively all the possible binary values of the variables 25

  26. Non-Determinism Language class: ( n ) NTIME ( n ) NTIME L 1 L 3 L 2 A Non-Deterministic Turing Machine accepts each string of length n in time ( n ) O 26

  27. L  Example: { ww } Non-Deterministic Algorithm to accept a string : ww • Use a two-tape Turing machine • Guess the middle of the string and copy on the second tape w • Compare the two tapes 27

  28. L  { ww } Time needed: • Use a two-tape Turing machine • Guess the middle of the string (| w |) O and copy on the second tape w • Compare the two tapes (| w |) O Total time: (| w |) O 28

  29. ( n ) NTIME L  { ww } 29

  30. In a similar way we define the class ( ( )) NTIME T n for any time function: ( n ) T 2 3 Examples: ( ), ( ),... NTIME n NTIME n 30

  31. Non-Deterministic Polynomial time algorithms: L  ( k ) NTIME n 31

  32. The class NP   ( k for all k ) NP P NTIME n Non-Deterministic Polynomial time 32

  33. The satisfiability problem Example: L  { : expression is satisfiabl e} w w Non-Deterministic algorithm: • Guess an assignment of the variables • Check if this is a satisfying assignment 33

  34. L  { : expression is satisfiabl e} w w Time for variables: n • Guess an assignment of the variables ( n ) O • Check if this is a satisfying assignment ( n ) O Total time: ( n ) O 34

  35. L  { : expression is satisfiabl e} w w L  NP The satisfiability problem is an - Problem NP 35

  36. Observation: P  NP Deterministic Non-Deterministic Polynomial Polynomial 36

  37. P  Open Problem: ? NP WE DO NOT KNOW THE ANSWER 37

  38. P  Open Problem: ? NP Example: Does the Satisfiability problem have a polynomial time deterministic algorithm? WE DO NOT KNOW THE ANSWER 38

  39. NP-Completeness A problem is NP-complete if: • It is in NP • Every NP problem is reduced to it (in polynomial time) 39

  40. Polynomial Time Reductions Polynomial Computable function : f For any computes w ( w ) f in polynomial time 40

  41. Language A is polynomial time reducible to language B if there is a polynomial computable function such that: f    ( ) w A f w B 41

  42. Theorem: Suppose that is polynomial reducible to . A B B  A  If then . P P Proof: Let be the machine to accept B M Machine to accept in polynomial time: A On input : w 1. Compute ( w ) f 2. Run on input ( w ) M f 42

  43. 3CNF formula:            ( ) ( ) ( ) ( ) x x x x x x x x x x x x 1 2 3 3 5 6 3 6 4 4 5 6 Each clause has three literals Language: 3SAT ={ : is a satisfiable w w 3CNF formula} 43

  44. Clique: A 5-clique CLIQUE = { : contains a -clique}   k G , G k 44

  45. Theorem: 3SAT is polynomial time reducible to CLIQUE Proof: give a polynomial time reduction of one problem to the other 45

  46.         ( ) ( ) ( ) x x x x x x x x x 1 1 2 1 2 2 1 2 3 x x x 2 1 2 x x 1 1 x x 1 2 x x 2 3 46

  47.         ( ) ( ) ( ) x x x x x x x x x  1 1 2 1 2 2 1 2 3 1 x 1  0 x 2  1 x 3 x x x 2 1 2 x x 1 1 x x 1 2 x x 2 3 47

  48. Cook’s Theorem: The satisfiability problem is NP-complete Proof: Convert a Non-Deterministic Turing Machine to a Boolean expression in conjunctive normal form 48

  49. Other NP-Complete Problems: • The Traveling Salesperson Problem • Vertex cover • Hamiltonian Path All the above are reduced to the satisfiability problem 49

  50. Observation: If we can solve any NP-complete problem in Deterministic Polynomial Time (P time) then we know: P  NP 50

  51. Observation: If we prove that we cannot solve an NP-complete problem in Deterministic Polynomial Time (P time) then we know: P  NP 51

  52. Observations: It is unlikely that NP-complete problems are in P The NP-complete problems have exponential time algorithms Approximations of these problems are in P 52

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