1 / 15

Measuring Complexity

Measuring Complexity. Lecture 36 Section 7.1 Fri, Nov 16, 2007. Time Complexity Classes. Let t : N  R + be a function. The time complexity class TIME( t ( n )) is the set of all languages that are decidable by an O ( t ( n )) Turing machine. Examples. SHIFT is in TIME( n ).

moshe
Download Presentation

Measuring 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. Measuring Complexity Lecture 36 Section 7.1 Fri, Nov 16, 2007

  2. Time Complexity Classes • Let t : N  R+ be a function. • The time complexity class TIME(t(n)) is the set of all languages that are decidable by an O(t(n)) Turing machine.

  3. Examples • SHIFT is in TIME(n). • COPY is in TIME(n2). • INCR and DECR are in TIME(n). • If ADD uses INCR and DECR, then what is the time complexity class of ADD? • If MULT uses ADD, then what is the time complexity class of MULT?

  4. Integer Factorization • Let the input be an n-bit integer k. • Suppose a Turing machine uses the following strategy to factor the integer. • Divide k by each integer from 2 to k – 1. • Assume division requires constant time.

  5. Integer Factorization • What will be the run time of this machine?

  6. Single Tape vs. Multitape • Theorem: If a problem P is in TIME(t(n)) for k-tape Turing machine and t(n)  n, then it is in TIME(t2(n)) for a single-tape Turing machine.

  7. Single Tape vs. Multitape • Proof: • The single-tape equivalent S of the multitape machine M records the contents of the k tapes of M on its single tape. • That requires O(n) steps. • In the t(n) transitions of M, it can scan at most t(n) cells of each of its tapes. Call that the “active” portion.

  8. Single Tape vs. Multitape • For each transition of S: • S scans the tape once to determine the current symbol on each tape. • The time required by the scan is at most kt(n) = O(t(n)). • Then S simulates on each portion of its tape the action of M on each of its tapes. • That action may require shifting right all remaining cells.

  9. Single Tape vs. Multitape • Each shift requires up to time t(n). • The time required is at most t(n) O(t(n)) = O(t2(n)). • The total is O(n) + O(t2(n)) = O(t2(n)).

  10. Deterministic vs. Nondeterministic • Theorem: If a problem P is in TIME(t(n)) for a nondeterministic Turing machine, then it is in TIME(2O(t(n))) for a deterministic Turing machine.

  11. Deterministic vs. Nondeterministic • Proof: • Let N be a nondeterministic Turing machine that decides P. • Consider a tree whose branches represent the different possible execution paths of N. • Let b be the largest number of branches at any node of the tree.

  12. Deterministic vs. Nondeterministic • No path through the tree can have length greater than t(n). • So the total number of leaves is no greater than bt(n). • A deterministic Turing machine D will do a breadth-first search of the tree, searching for the accept state.

  13. Deterministic vs. Nondeterministic • For every node searched, D begins at the root node and follows the path to that node. • That requires time at most t(n). • The number of nodes is less than twice the number of leaves. • So there are at most 2bt(n) nodes.

  14. Deterministic vs. Nondeterministic • The total search time required is at most O(t(n)(2bt(n))) = O(bO(t(n))). • So D is in TIME(bO(t(n))). • Finally, D is a 3-tape machine. • It can be simulated by a single-tape machine that is in TIME((bO(t(n)))2) = TIME(2O(t(n))).

  15. Example • The factoring problem can be solved nondeterministically in O(n) time, where n equals the length of the number. (How?) • Therefore, the factoring problem can be solved deterministically in O(2O(n)) time.

More Related