Polynomial time vs. polynomial space

759 Views Asked by At

In my opinion it is trivial that if an algorithm is polynomial time in its input length then it is also polynomial space. Is this true and really trivial or do I overlook something? If it is wrong, what counterexamples do we have?

(I know that for decision problems we have $PTIME \subseteq PSPACE$. But I am not sure if this also holds for algorithms of other problems like computing a function, arithmetic operations, etc.)

1

There are 1 best solutions below

0
On BEST ANSWER

If a Turing Machine takes polynomial time $p(|w|)$, where $w$ is an arbitrary input string, then the TM uses at most $p(|w|)$ tape cells (one cell for each step). So it takes polynomial space.

Note that a decision problem is a language, or a function of the form $f : \{0,1\}^* \to \{0,1\}$. That is, $f(w) = 1$ if and only if $w$ is in your language.