In computational complexity theory, Savitch's theorem, proved by Walter Savitch in 1970, gives a relationship between deterministic and non-deterministic space complexity. It states that for any space-constructable function f ∈ Ω ( log ( n ) ) {\displaystyle f\in \Omega (\log(n))} ,
N S P A C E ( f ( n ) ) ⊆ D S P A C E ( f ( n ) 2 ) . {\displaystyle {\mathsf {NSPACE}}\left(f\left(n\right)\right)\subseteq {\mathsf {DSPACE}}\left(f\left(n\right)^{2}\right).}
In other words, if a nondeterministic Turing machine can solve a problem using f ( n ) {\displaystyle f(n)} space, a deterministic Turing machine can solve the same problem in the square of that space bound. Although it seems that nondeterminism may produce exponential gains in time (as formalized in the unproven exponential time hypothesis), Savitch's theorem shows that it has a markedly more limited effect on space requirements. The theorem can be relativized. That is, for any oracle, replacing every "Turing machine" with "oracle Turing machine" would still result in a theorem.
Proof The proof relies on an algorithm for STCON, the problem of determining whether there is a path between two vertices in a directed graph, which runs in O ( ( log n ) 2 ) {\displaystyle O\left((\log n)^{2}\right)} space for n {\displaystyle n} vertices. The basic idea of the algorithm is to solve recursively a somewhat more general problem, testing the existence of a path from a vertex s {\displaystyle s} to another vertex t {\displaystyle t} that uses at most k {\displaystyle k} edges, for a parameter k {\displaystyle k} given as input. STCON is a special case of this problem where k {\displaystyle k} is set large enough to impose no restriction on the paths (for instance, equal to the total number of vertices in the graph, or any larger value). To test for a k {\displaystyle k} -edge path from s {\displaystyle s} to t {\displaystyle t} , a deterministic algorithm can iterate through all vertices u {\displaystyle u} , and recursively search for paths of half the length from s {\displaystyle s} to u {\displaystyle u} and from u {\displaystyle u} to t {\displaystyle t} . This algorithm can be expressed in pseudocode (in Python syntax) as follows:
… excerpt ends here. Continue reading the full article.
