Skip to content

25. Space Complexity

Apr 14, 2022

Space complexity f(n):

PSPACE(f(n))

All deterministic decidable languages that use O(f(n)) space.

  • for deterministic Turing machine: maximum number of cells that the machine scans on any input string of size n => total space used f(n).

NSPACE(f(n))

all non-deterministic decidable languages that use O(f(n)) space.

  • for non-deterministic Turing machine: maximum number of cells that the machine scans on any input string of size n in any computation path

Note: space is always bounded by time.

Examples:

  • SAT is a linear space problem -- given a formula, we can check in linear space every possible assignment to variables.

  • An interesting problem: ALLNFA -- it is not known if it is in NP, however the problem is in NSPACE(n)


Savitch's Theorem

NSPACE(f(n)) SPACE(f2(n))   f(n)n


Given NTWM N that decides in f(n) space, build DTM M that decides in O(f2(n)) space. Assume NTM N clears the tape when it accepts and enters a special configuration caccept. Key idea: CANYIELD(c1,c2,t) => does configuration c1 yield c2 in t steps?

=> recursion: CANYIELD(c1,c2,t) => CANYIELD(c1,cm,t/2) => CANYIELD(cm,c2,t/2)

Possibilities for cm:2df(n)

Run CANYIELD(cstart,caccept,2df(n))

  • depth of search tree: log(2df(n))=O(f(n))
  • information stored at each tree level: O(f(n))
  • total space: O(f2(n))

Difficulty: f(n) is not known -- guess.

Check also if space used by NTM is more than f(n).


PSPACE=kSPACE(nk)

NPSPACE=kNSPACE(nk)

  • Trivially: PSPACE NPSPACE
  • From Savitch's theorem: NPSPACE PSPACE

=> PSPACE = NPSPACE

P NP PSPACE = NPSPACE EXPTIME