# NTIME(f) subset of DSPACE(f)

As the question states, how do we prove that $\textbf{NTIME}(f(n)) \subseteq \textbf{DSPACE}(f(n))$?

Can anyone point me to a proof or outline it here? Thanks!

• I guess there are mult. constants hiding there. You can prove that $NTIME(f(n)) \subseteq DSPACE(2\cdot f(n))$. Just enumerate over all possible non-deterministic guesses of the algorithm, and run your algorithm with these guesses. Accept if one of the guesses leads to an accepting state. – Igor Shinkar Sep 20 '13 at 17:01
• Why not make this an answer? – Yuval Filmus Sep 20 '13 at 17:45
• @IgorShinkar There are various results, such as the linear speedup theorem and the tape compression theorem that say you can get rid of those constants in "most" circumstances. Linear speedup says that $\mathrm{DTIME}(f(n)) \subseteq \mathrm{DTIME}(\epsilon f(n)+n+2)$ for any $\epsilon>0$; tape compression says that $\mathrm{DSPACE}(f(n))\subseteq \mathrm{DSPACE}(\epsilon f(n) + O(1))$, again for any $\epsilon>0$. – David Richerby Sep 21 '13 at 0:04

Here is an expanded version of Igor Shinkar's comment. The simplest way to simulate a non-deterministic machine running in time $f(n)$ and space $s(n) \leq f(n)$ uses $s(n) + 2f(n) + O(1)$ space. We enumerate over all possible coin tosses, simulating the original machine on each of them; this requires space $f(n)$ for storing the coin tosses, and $s(n)$ space for simulating the actual machine. There is a slight difficulty here: when the coin tosses are "read" by the (original) machine, we need to mark somehow where we are in the sequence of coin tosses; we can use an additional bit per coin toss. It is probably possible to optimize this even further.
If we're careful, we might be able to get something even better, since in each run of the program, the total number of coin tosses and the total space used add together to at most $f(n)$. I suspect it's possible to run the simulation in $(1+o(1))f(n)$ space. Perhaps we will need to assume something like $f(n) = \Omega(\log n)$ for that.
As Igor mentions, usually resource-bounded classes are only defined "up to big O", so that the result, which uses space $O(f(n))$, is still in $\mathrm{DSPACE}(f(n))$.