Efficient Algorithms and Problem Complexity – More Complexity Classes – Frank Drewes Department of Computing Science Umeå University Frank Drewes (Umeå University) Efficient Algorithms and Problem Complexity Lecture 14 1 / 12
Outline Today’s Menu Space Complexity 1 Complement Classes 2 Frank Drewes (Umeå University) Efficient Algorithms and Problem Complexity Lecture 14 2 / 12
Space Complexity Memory Space – Another Precious Resource Instead of asking how quickly a problem can be solved, we may ask how much memory is required. To study memory requirements, Turing machines (TMs) are more suitable than RAMs. The use of RAMs would create problems because arbitrarily large numbers fit in one register. Frank Drewes (Umeå University) Efficient Algorithms and Problem Complexity Lecture 14 3 / 12
Space Complexity How to Define the Memory Requirements of an Algorithm? Important aspects to keep in mind: In contrast to time, memory can be re-used. The input is in memory, but should not be viewed as used memory ⇒ input should be read-only. However, if we use additional memory, this is usage that should count. Output should not be counted either ⇒ output should be write-only. Frank Drewes (Umeå University) Efficient Algorithms and Problem Complexity Lecture 14 4 / 12
Space Complexity How to Define the Memory Requirements of an Algorithm? A suitable type of TM to take care of these aspects: We consider TMs M with ⋆ one read-only input tape ( M never writes anything on it), ⋆ k > 0 read-write work tapes, and ⋆ one write-only output tape ( M always moves one cell to the right when it has written a symbol on it). Consider a computation such that the right-most positions on the work tapes visited by the head are i 1 ,..., i k . Then i 1 +···+ i k is the space used. M is said to run in space f ( n ) if it uses at most f ( | x | ) space for every input x (where | x | denotes the length of x ). The corresponding definitions for nondeterministic space are similar. Frank Drewes (Umeå University) Efficient Algorithms and Problem Complexity Lecture 14 5 / 12
Space Complexity Space Complexity Classes General notation: DSPACE ( f ( n )) = all decision problems that are deterministically solvable in space f ( n ) . NSPACE ( f ( n )) = all decision problems that are nondeterministically solvable in space f ( n ) . Note: We only look at “well-behaved” functions f to exclude weird effects. The most important space complexity classes are L = DSPACE ( O (log n )) and NL = NSPACE ( O (log n )) . LIN = DSPACE ( O ( n )) and NLIN = NSPACE ( O ( n )) . k ∈ N DSPACE ( O ( n k )) . PSPACE = � Frank Drewes (Umeå University) Efficient Algorithms and Problem Complexity Lecture 14 6 / 12
Space Complexity Some Inclusions L ⊆ NL ⊆ P ⊆ NP ⊆ PSPACE = NPSPACE ⊆ EXP ⊆ NEXP (1) (2) (3) (4) (5) (6) (7) The inclusions (1) , (3) , (7) (and one direction of (5) ) are trivial. The proof of (4) uses depth-first search and the observation that a polynomial-time computation can only use polynomial space. (5) is Savitch’s Theorem which establishes for space what we would like to know for time (i.e, P = NP). The proofs of (2) , (5) , and (6) can all be seen as applications of the REACHABILITY method. Frank Drewes (Umeå University) Efficient Algorithms and Problem Complexity Lecture 14 7 / 12
Space Complexity REACHABILITY REACHABILITY Input: A directed graph G = ( V , E ) and nodes s , t ∈ V . Question: Is there a path in G from s to t ? Frank Drewes (Umeå University) Efficient Algorithms and Problem Complexity Lecture 14 8 / 12
Space Complexity The REACHABILITY Method The REACHABILITY method is based on the following observations: A nondet. TM M working in space f ( n ) has 2 O ( f ( n )) configurations ⇒ the set of configurations yields a digraph G M , x of size 2 O ( f ( n )) , where an edge ( c , c ′ ) means that a computation step leads from c to c ′ . Therefore, M ( x ) = 1 if and only if an accepting configuration is reachable from the initial configuration in G M , x . For graphs of size m , REACHABILITY ∈ DSPACE ( O ((log m ) 2 )) . ⇒ NSPACE ( O ( f ( n ))) ⊆ DSPACE ((log2 O ( f ( n )) ) 2 ) = DSPACE ( O ( f ( n ) 2 )). REACHABILITY can also easily be solved in time O ( m 2 ) ⇒ NSPACE ( O ( f ( n ))) ⊆ DTIME ((2 O ( f ( n )) ) 2 ) = DTIME (2 O ( f ( n )) ). In particular, NL ⊆ P and PSPACE = NPSPACE ⊆ EXP. Frank Drewes (Umeå University) Efficient Algorithms and Problem Complexity Lecture 14 9 / 12
Complement Classes Complement Classes Definition (complements) The complement of a decision problem A is A = { x | x ∉ A } . For a class C of problems, co C = { A | A ∈ C } . Strictly speaking, A also contains all ill-formed instances, but we usually consider only valid instances of a problem. Example: SAT is the set of all unsatisfiable Boolean formulas. For every deterministic complexity class C , we have co C = C . [WHY?] We say that deterministic classes are closed under complement. For nondeterministic complexity classes, this is not apriori clear. Frank Drewes (Umeå University) Efficient Algorithms and Problem Complexity Lecture 14 10 / 12
Complement Classes The Immerman-Szelepcsényi Theorem Nondeterministic space is closed under complement: Theorem (Immerman and Szelepcsényi) Let f ( n ) ≥ log n , and let C be the set of all problems that can be decided nondeterministically in space O ( f ( n )) . Then co C = C . The proof is a wonderful application of the REACHABILITY method, based on an algorithm that shows that REACHABILITY ∈ NL. Immerman and Szelepcsényi were awarded the Gödel prize for their result in 1995. Frank Drewes (Umeå University) Efficient Algorithms and Problem Complexity Lecture 14 11 / 12
Complement Classes The Situation for Polynomial Time coNPC NPC coNP NP P NP �= coNP if and only if NPC ∩ coNPC = � . But perhaps NP = coNP but P �= NP? If P �= NP then NP �= P ∪ NPC (and, of course, similarly for coNP). Frank Drewes (Umeå University) Efficient Algorithms and Problem Complexity Lecture 14 12 / 12
Recommend
More recommend