Page 1 Space Complexity CS60001: Foundations of Computing Science Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Page 2 Space Complexity CS60001: Foundations of Computing Science Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Indian Institute of Technology Kharagpur Pallab Dasgupta Introduction ? Definition ¦ Let M be a deterministic Turing machine that halts on all inputs. The space complexity of M is the function f: N ? N, where f(n) is the maximum number of tape cells that M scans on any input of length n. If the space complexity of M is f(n), we also say that M runs in space f(n) ¦ If M is a non-deterministic Turing machine wherein all branches halt on all inputs, we define its space complexity f(n) to be the maximum number of tape cells that M scans on any branch of its computation for any input of length n 2 Page 3 Space Complexity CS60001: Foundations of Computing Science Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Indian Institute of Technology Kharagpur Pallab Dasgupta Introduction ? Definition ¦ Let M be a deterministic Turing machine that halts on all inputs. The space complexity of M is the function f: N ? N, where f(n) is the maximum number of tape cells that M scans on any input of length n. If the space complexity of M is f(n), we also say that M runs in space f(n) ¦ If M is a non-deterministic Turing machine wherein all branches halt on all inputs, we define its space complexity f(n) to be the maximum number of tape cells that M scans on any branch of its computation for any input of length n 2 Indian Institute of Technology Kharagpur Pallab Dasgupta Space Complexity Classes ? Definition: Let f: N ? R + be a function. The space complexity classes, SPACE(f(n)) and NSPACE(f(n)), are defined as follows: ¦ SPACE(f(n)) = {L | L is a language decided by O(f(n)) space deterministic Turing machine} ¦ NSPACE(f(n)) = {L | L is a language decided by an O(f(n)) space non-deterministic Turing machine} ? Examples ¦ SAT can be solved with a linear space algorithm [Space complexity = O(n)] ¦ Testing whether a non-deterministic finite automaton accepts all strings, i.e. ALL NFA = {<A> | A is a NFA and L(A) = S*} ? Non-deterministic space complexity = O(n) ? SAVITCH’S Theorem ¦ For any function f: N ? R + , where f(n) = n, NSPACE(f(N)) SPACE(f 2 (n)) 3 UI Page 4 Space Complexity CS60001: Foundations of Computing Science Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Indian Institute of Technology Kharagpur Pallab Dasgupta Introduction ? Definition ¦ Let M be a deterministic Turing machine that halts on all inputs. The space complexity of M is the function f: N ? N, where f(n) is the maximum number of tape cells that M scans on any input of length n. If the space complexity of M is f(n), we also say that M runs in space f(n) ¦ If M is a non-deterministic Turing machine wherein all branches halt on all inputs, we define its space complexity f(n) to be the maximum number of tape cells that M scans on any branch of its computation for any input of length n 2 Indian Institute of Technology Kharagpur Pallab Dasgupta Space Complexity Classes ? Definition: Let f: N ? R + be a function. The space complexity classes, SPACE(f(n)) and NSPACE(f(n)), are defined as follows: ¦ SPACE(f(n)) = {L | L is a language decided by O(f(n)) space deterministic Turing machine} ¦ NSPACE(f(n)) = {L | L is a language decided by an O(f(n)) space non-deterministic Turing machine} ? Examples ¦ SAT can be solved with a linear space algorithm [Space complexity = O(n)] ¦ Testing whether a non-deterministic finite automaton accepts all strings, i.e. ALL NFA = {<A> | A is a NFA and L(A) = S*} ? Non-deterministic space complexity = O(n) ? SAVITCH’S Theorem ¦ For any function f: N ? R + , where f(n) = n, NSPACE(f(N)) SPACE(f 2 (n)) 3 UI Indian Institute of Technology Kharagpur Pallab Dasgupta The Class PSPACE ? Definition ¦ PSPACE is the class of languages that are decidable in polynomial space on a deterministic Turing machine. In other words, PSPACE = U SPACE(n k ) ¦ NPSPACE is the class of languages that are decidable in polynomial space on a non-deterministic Turing machine. In other words, NPSPACE = U NSPACE(n k ) ? Relationship among the Complexity Classes ¦ P NP PSPACE = NPSPACE EXPTIME 4 k k UI UI UI P NP PSPACE EXPTIME Page 5 Space Complexity CS60001: Foundations of Computing Science Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Indian Institute of Technology Kharagpur Pallab Dasgupta Introduction ? Definition ¦ Let M be a deterministic Turing machine that halts on all inputs. The space complexity of M is the function f: N ? N, where f(n) is the maximum number of tape cells that M scans on any input of length n. If the space complexity of M is f(n), we also say that M runs in space f(n) ¦ If M is a non-deterministic Turing machine wherein all branches halt on all inputs, we define its space complexity f(n) to be the maximum number of tape cells that M scans on any branch of its computation for any input of length n 2 Indian Institute of Technology Kharagpur Pallab Dasgupta Space Complexity Classes ? Definition: Let f: N ? R + be a function. The space complexity classes, SPACE(f(n)) and NSPACE(f(n)), are defined as follows: ¦ SPACE(f(n)) = {L | L is a language decided by O(f(n)) space deterministic Turing machine} ¦ NSPACE(f(n)) = {L | L is a language decided by an O(f(n)) space non-deterministic Turing machine} ? Examples ¦ SAT can be solved with a linear space algorithm [Space complexity = O(n)] ¦ Testing whether a non-deterministic finite automaton accepts all strings, i.e. ALL NFA = {<A> | A is a NFA and L(A) = S*} ? Non-deterministic space complexity = O(n) ? SAVITCH’S Theorem ¦ For any function f: N ? R + , where f(n) = n, NSPACE(f(N)) SPACE(f 2 (n)) 3 UI Indian Institute of Technology Kharagpur Pallab Dasgupta The Class PSPACE ? Definition ¦ PSPACE is the class of languages that are decidable in polynomial space on a deterministic Turing machine. In other words, PSPACE = U SPACE(n k ) ¦ NPSPACE is the class of languages that are decidable in polynomial space on a non-deterministic Turing machine. In other words, NPSPACE = U NSPACE(n k ) ? Relationship among the Complexity Classes ¦ P NP PSPACE = NPSPACE EXPTIME 4 k k UI UI UI P NP PSPACE EXPTIME Indian Institute of Technology Kharagpur Pallab Dasgupta PSPACE-Completeness ? Definition ¦ A language B is PSPACE-complete if it satisfies two conditions: ? B is in PSPACE, and ? Every A in PSPACE is polynomial time reducible to B ¦ If B merely satisfies condition-2, we say that it is PSPACE-hard ? Examples of PSPACE-complete Problems ¦ TQBF = {<F> | F is a true fully quantified Boolean formula} ¦ FORMULA-GAME = {<F> | Player E has a winning strategy in the formula game associated with F} ¦ GENERALIZED-GEOGRAPHY = {<G, b> | Player I has a winning strategy for the generalized geography game played on the graph G starting at node b} 5Read More

Offer running on EduRev: __Apply code STAYHOME200__ to get INR 200 off on our premium plan EduRev Infinity!