1 / 33

Time Complexity

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. Example:. Algorithm to accept a string :. Use a two-tape Turing machine Copy the on the second tape Compare the and. Time needed:.

Download Presentation

Time Complexity

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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 COMP 335

  2. Example: Algorithm to accept a string : • Use a two-tape Turing machine • Copy the on the second tape • Compare the and COMP 335

  3. Time needed: • Copy the on the second tape • Compare the and Total time: COMP 335

  4. For string of length time needed for acceptance: COMP 335

  5. Language class: A Deterministic Turing Machine accepts each string of length in time COMP 335

  6. COMP 335

  7. In a similar way we define the class for any time function: Examples: COMP 335

  8. Example: The membership problem for context free languages (CYK - algorithm) Polynomial time COMP 335

  9. Theorem: COMP 335

  10. Polynomial time algorithms: Represent tractable algorithms: For small we can compute the result fast COMP 335

  11. The class for all • Polynomial time • All tractable problems COMP 335

  12. CYK-algorithm COMP 335

  13. Exponential time algorithms: Represent intractable algorithms: Some problem instances may take centuries to solve COMP 335

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

  15. s t YES! COMP 335

  16. A solution: search exhaustively all paths L = {<G,s,t>: there is a Hamiltonian path in G from s to t} Exponential time Intractable problem COMP 335

  17. Example: The Satisfiability Problem Boolean expressions in Conjunctive Normal Form: Variables Question: is expression satisfiable? COMP 335

  18. Example: Satisfiable: COMP 335

  19. Example: Not satisfiable COMP 335

  20. For variables: exponential Algorithm: search exhaustively all the possible binary values of the variables COMP 335

  21. Non-Determinism Language class: A Non-Deterministic Turing Machine accepts each string of length in time COMP 335

  22. Example: Non-Deterministic Algorithm to accept a string : • Use a two-tape Turing machine • Guess the middle of the string • and copy on the second tape • Compare the two tapes COMP 335

  23. Time needed: • Use a two-tape Turing machine • Guess the middle of the string • and copy on the second tape • Compare the two tapes Total time: COMP 335

  24. COMP 335

  25. In a similar way we define the class for any time function: Examples: COMP 335

  26. Non-Deterministic Polynomial time algorithms: COMP 335

  27. The class for all Non-Deterministic Polynomial time COMP 335

  28. The satisfiability problem Example: Non-Deterministic algorithm: • Guess an assignment of the variables • Check if this is a satisfying assignment COMP 335

  29. Time for variables: • Guess an assignment of the variables • Check if this is a satisfying assignment Total time: COMP 335

  30. The satisfiability problem is an - Problem COMP 335

  31. Observation: Deterministic Polynomial Non-Deterministic Polynomial COMP 335

  32. Open Problem: WE DO NOT KNOW THE ANSWER COMP 335

  33. Open Problem: Example: Does the Satisfiability problem have a polynomial time deterministic algorithm? WE DO NOT KNOW THE ANSWER COMP 335

More Related