<p>In some sense yes, specifically as of right now we have that:</p>

<p>$\textbf{DTIME}(S(n)) \subseteq \textbf{SPACE}(S(n)) \subseteq \textbf{NSPACE}(S(n)) \subseteq \textbf{DTIME}(2^{O(S(n))})$</p>

<p>And also we know that $\textbf{PSPACE} \subsetneq \textbf{EXPSPACE}$
So that also implies $\textbf{P} \subsetneq \textbf{EXPSPACE}$.</p>

<p>Though we don't know what the specific relationships are for example between P and PSPACE, i.e. "is P a proper subset or are they the same?"</p>

<p>As for your question, one thing to note is that the space complexity is always upper bounded by time, since we cannot have that we use $g(n)$ space and $f(n)$ time when $f(n) = \textbf{o}(g(n))$, else it would mean the TM is accessing more cells without needing that many steps. </p>

<p>So for $\textbf{L}_1$ to be in $f(n)$ time and $g(n)$ space would firstly imply that $f(n)$ is somewhat either equals to or larger than $g(n)$. And it'll be the case that it takes more than $g(n)$ space as long as the actual complexity is less than $f(n)$.</p>

<p>Then for $\textbf{L}_2$ since it'll take more than $f(n)$ time, and $g(n)$ space, this is possible as long as we just let the actual time complexity be bigger than $f(n)$ (since the space complexity is already smaller anyway).</p>

<p>Then it'll depend on whether on $\textbf{L}_2$ is in something like $\textbf{EXP}$ whereas $\textbf{L}_1$ is in $\textbf{P}$ for us to conclusively say anything about their relative difficulty, since then we know $\textbf{P} \subsetneq \textbf{EXP}$.</p>

<p>Besides that as far as I know, we can't really tell, since the best we've done so far is the theorem that I firstly mentioned. </p>

<p>I'm sure you can craft up example for things that take greater time and less space as compared to other algorithms. I can't think of any examples of decision problems right now but consider something like dynamic programming, where you can decrease time complexity whilst increasing space complexity. </p>

<p>If you want to know more about that theorem you can try "Computational Complexity: A Modern Approach" by Sanjeev Arora and Boaz Barak
The theorem is mentioned on page 76.</p>

CC BY-SA 3.0
2018-02-18T19:39:04.017Z
Thank you for your answer! However, I wasn't looking for results comparing the two hierarchies (I am already familiar with the results you cited). I was looking for languages for which the time hierarchy says $L_2$ is more complex but the space hierarchy says $L_1$ is more complex.
exfret
CC BY-SA 3.0
2018-02-19T00:43:54.060Z
How about $L_1$ = { <s, t, G> : s is connected to t in directed graph G} and $L_2$ = { <array, d> : there exists a pair of integers in the array such that their sum is d}. $L_1$ can be decided in deterministic linear time and space, whereas $L_2$ can be decided in deterministic quadratic time and logarithmic space. So just set $f(n)$ = O(n) and $g(n)$ to be log(n) and I suppose this example should show there are languages that fit your example? It sure is an interesting question and I don't think I know more about this to give a more well informed answer.
CurryKatsuCutlet
CC BY-SA 3.0
2018-02-20T14:07:05.373Z
Sadly $L_1\in NL$, and it is not known whether $L=NL$. If this were to be true, your example would be incorrect, since then $L_1$ would take logarithmic space.
exfret
CC BY-SA 3.0
2018-02-20T15:35:35.997Z
Hmm yeah that's true. An oversight on my part
CurryKatsuCutlet
CC BY-SA 3.0
2018-02-18T18:33:38.187Z
2018-02-18T18:33:38.187Z
CurryKatsuCutlet
<p>You can get the situation you describe by choosing weird functions $f(n)$ and $g(n)$. </p>

<p>For example, let $g(n) = n^3$ and $$f(n) = \begin{cases}
 n &amp; \text{if $n$ is odd},
\\\
 2^{n^5} &amp; \text{if $n$ is even}.
\end{cases}
$$</p>

<p>Then choose $L_1$ and $L_2$ as follows:</p>

<p>$L_1$ is a language containing only strings of even length which can be decided in time $O(2^{n^5})$ but not in time $O(2^{n^4})$. The existence of such a language is pretty easy to prove from the time hierarchy theorem.</p>

<p>$L_2$ is a language containing only strings of odd length which can be decided in space $O(n^3)$ but not in space $O(n^2)$. The existence of such a language is pretty easy to prove from the space hierarchy theorem.</p>

<p>Then we have the following facts:</p>

<h2>$L_1 \in TIME(f(n))$:</h2>

<p>To decide whether a string is in $L_1$, simply check whether the length $n$ is even. If it is, then continue to use the $O(2^{n^5})$ time decider for $L_1$ whose existence is guaranteed by the definition of $L_1$. If $n$ is odd, immediately reject since $L_1$ does not include any odd length strings anyway. This procedure decides $L_1$, runs in time $O(n)$ when $n$ is odd, and runs in time $O(2^{n^5})$ when $n$ is even. In other words, this procedure decides $L_1$ in time $O(f(n))$. As desired, $L_1 \in TIME(f(n))$.</p>

<h2>$L_2 \in SPACE(g(n))$:</h2>

<p>By the definition of $L_2$, $L_2$ can be decided in space $O(n^3)$. Thus, $L_2 \in SPACE(n^3) = SPACE(g(n))$, as desired.</p>

<h2>$L_1 \not\in SPACE(g(n))$:</h2>

<p>Suppose for the sake of contradiction that $L_1 \in SPACE(g(n)) = SPACE(n^3)$. We know that $SPACE(n^3) \subseteq TIME(2^{O(n^3)}) \subsetneq TIME(2^{n^4})$. Thus, there exists a decider for $L_1$ which runs in time $O(2^{n^4})$. This directly contradicts the definition of $L_1$. Then by contradiction, we see that $L_1 \not\in SPACE(g(n))$.</p>

<h2>$L_2 \not\in TIME(f(n))$:</h2>

<p>Suppose for the sake of contradiction that $L_2 \in TIME(f(n))$. This means that there exists a constant $c$ and an algorithm $A$ deciding $L_2$ such that on any input of size $n$, algorithm $A$ terminates in time $c\times f(n)$. </p>

<p>We construct a new algorithm $A'$ as follows: given some input, walk through the entire input, keeping track of whether the input length is even or odd; if at the end of the input the length is determined to be odd, return to the start of the input and run $A$; otherwise, reject. For any input of odd length, $A'$ returns the same answer as $A$. For any input of even length, $A'$ rejects, which matches the expected behavior since $L_2$ contains no even length strings. Thus, $A'$ also decides $L_2$. On even length inputs, $A'$ runs for exactly $n$ steps. On odd length inputs, $A'$ runs for exactly $2n$ steps more than $A$ requires. But $A$ requires at most $c\times f(n)$ steps, which for odd $n$ is $cn$. Thus, in all cases, $A'$ runs in at most $(c+2)n$ steps. In other words, algorithm $A'$ decides $L_2$ in time $O(n)$. </p>

<p>But since $TIME(n) \subseteq SPACE(n)$, we can conclude that $L_2 \in SPACE(n) \subsetneq SPACE(n^2)$. This contradicts the definition of $L_2$. Thus, by contradiction we see that $L_2 \not\in TIME(f(n))$.</p>

CC BY-SA 3.0
2018-02-19T15:10:57.780Z
Nice! I wonder whether there are examples where both $f,g$ are elementary...
Joshua Grochow
CC BY-SA 3.0
2018-02-19T07:19:22.320Z
2018-02-19T07:19:22.320Z
Mikhail Rudoy
<p>I am wondering if there are any results to what extent the space and time hierarchies "disagree" on which problem is harder. For example, is it known whether there are languages $L_1$ and $L_2$ such that $L_1 \in \DeclareMathOperator{TIME}{TIME} \TIME(f(n))\setminus SPACE(g(n)),L_2\in \DeclareMathOperator{SPACE}{SPACE} \SPACE(g(n)) \setminus \TIME(f(n))$? How often does this occur?</p>

<p>P.S.- The question <a href="https://cstheory.stackexchange.com/questions/12512/function-with-space-depending-computation-time">Function with space-depending computation time</a> seems to ask something similar but was worded confusingly and none of the answers seem to be what I'm looking for.</p>

CC BY-SA 3.0
2018-02-18T01:49:38.110Z
Note that doing this for most standard robust classes (instead of $\mathsf{TIME}(t(n))$ vs $\mathsf{SPACE}(s(n))$) would solve open problems. For example, one natural candidate would be $\mathsf{QP}$ vs. $\mathsf{PSPACE}$. If we could find a function in $\mathsf{QP} \backslash \mathsf{PSPACE}$, that implies $\mathsf{PSPACE} \neq \mathsf{EXP}$, and if we could find a function in $\mathsf{PSPACE} \backslash \mathsf{QP}$ it would imply $\mathsf{P} \neq \mathsf{PSPACE}$. Similarly, finding a function in $\mathsf{P} \backslash \mathsf{L}^2$ would separate $\mathsf{P}$ from $\mathsf{NL}$.
Joshua Grochow
CC BY-SA 3.0
2018-02-18T19:47:08.077Z
Yes, that is a problem. Do you think that this could be remedied by choosing "weirder" complexity classes? They should still be time/space-constructible of course, but perhaps there are more artificial examples of this happening. For example, it seems like choosing $f(n)=n,g(n)=loglogn$ would be hopeful and this wouldn't require solving any huge complexity-theoretic conjectures as far as I know.
exfret
<time-complexity><space-complexity><space-time-tradeoff><time-hierarchy>
Are space and time hierarchies even comparable?
exfret
# Are space and time hierarchies even comparable?

(Asked by: username_0 on 2018-02-17)

I am wondering if there are any results to what extent the space and time hierarchies "disagree" on which problem is harder. For example, is it known whether there are languages $L\_1$ and $L\_2$ such that $L\_1 \in \DeclareMathOperator{TIME}{TIME} \TIME(f(n))\setminus SPACE(g(n)),L\_2\in \DeclareMathOperator{SPACE}{SPACE} \SPACE(g(n)) \setminus \TIME(f(n))$? How often does this occur?

P.S.- The question [Function with space-depending computation time](https://cstheory.stackexchange.com/questions/12512/function-with-space-depending-computation-time) seems to ask something similar but was worded confusingly and none of the answers seem to be what I'm looking for.

**Tags:** time-complexity, space-complexity, space-time-tradeoff, time-hierarchy
> **Comments:**
> **username_1**: Note that doing this for most standard robust classes (instead of $\mathsf{TIME}(t(n))$ vs $\mathsf{SPACE}(s(n))$) would solve open problems. For example, one natural candidate would be $\mathsf{QP}$ vs. $\mathsf{PSPACE}$. If we could find a function in $\mathsf{QP} \backslash \mathsf{PSPACE}$, that implies $\mathsf{PSPACE} \neq \mathsf{EXP}$, and if we could find a function in $\mathsf{PSPACE} \backslash \mathsf{QP}$ it would imply $\mathsf{P} \neq \mathsf{PSPACE}$. Similarly, finding a function in $\mathsf{P} \backslash \mathsf{L}^2$ would separate $\mathsf{P}$ from $\mathsf{NL}$.  
> **username_0**: Yes, that is a problem. Do you think that this could be remedied by choosing "weirder" complexity classes? They should still be time/space-constructible of course, but perhaps there are more artificial examples of this happening. For example, it seems like choosing $f(n)=n,g(n)=loglogn$ would be hopeful and this wouldn't require solving any huge complexity-theoretic conjectures as far as I know.  

---

## 2 answers

### Answer by username_3 on 2018-02-19. Score: 10 | Accepted answer

You can get the situation you describe by choosing weird functions $f(n)$ and $g(n)$.

For example, let $g(n) = n^3$ and $$f(n) = \begin{cases}
n & \text{if $n$ is odd},
\\\
2^{n^5} & \text{if $n$ is even}.
\end{cases}
$$

Then choose $L\_1$ and $L\_2$ as follows:

$L\_1$ is a language containing only strings of even length which can be decided in time $O(2^{n^5})$ but not in time $O(2^{n^4})$. The existence of such a language is pretty easy to prove from the time hierarchy theorem.

$L\_2$ is a language containing only strings of odd length which can be decided in space $O(n^3)$ but not in space $O(n^2)$. The existence of such a language is pretty easy to prove from the space hierarchy theorem.

Then we have the following facts:

## $L\_1 \in TIME(f(n))$:

To decide whether a string is in $L\_1$, simply check whether the length $n$ is even. If it is, then continue to use the $O(2^{n^5})$ time decider for $L\_1$ whose existence is guaranteed by the definition of $L\_1$. If $n$ is odd, immediately reject since $L\_1$ does not include any odd length strings anyway. This procedure decides $L\_1$, runs in time $O(n)$ when $n$ is odd, and runs in time $O(2^{n^5})$ when $n$ is even. In other words, this procedure decides $L\_1$ in time $O(f(n))$. As desired, $L\_1 \in TIME(f(n))$.

## $L\_2 \in SPACE(g(n))$:

By the definition of $L\_2$, $L\_2$ can be decided in space $O(n^3)$. Thus, $L\_2 \in SPACE(n^3) = SPACE(g(n))$, as desired.

## $L\_1 \not\in SPACE(g(n))$:

Suppose for the sake of contradiction that $L\_1 \in SPACE(g(n)) = SPACE(n^3)$. We know that $SPACE(n^3) \subseteq TIME(2^{O(n^3)}) \subsetneq TIME(2^{n^4})$. Thus, there exists a decider for $L\_1$ which runs in time $O(2^{n^4})$. This directly contradicts the definition of $L\_1$. Then by contradiction, we see that $L\_1 \not\in SPACE(g(n))$.

## $L\_2 \not\in TIME(f(n))$:

Suppose for the sake of contradiction that $L\_2 \in TIME(f(n))$. This means that there exists a constant $c$ and an algorithm $A$ deciding $L\_2$ such that on any input of size $n$, algorithm $A$ terminates in time $c\times f(n)$.

We construct a new algorithm $A'$ as follows: given some input, walk through the entire input, keeping track of whether the input length is even or odd; if at the end of the input the length is determined to be odd, return to the start of the input and run $A$; otherwise, reject. For any input of odd length, $A'$ returns the same answer as $A$. For any input of even length, $A'$ rejects, which matches the expected behavior since $L\_2$ contains no even length strings. Thus, $A'$ also decides $L\_2$. On even length inputs, $A'$ runs for exactly $n$ steps. On odd length inputs, $A'$ runs for exactly $2n$ steps more than $A$ requires. But $A$ requires at most $c\times f(n)$ steps, which for odd $n$ is $cn$. Thus, in all cases, $A'$ runs in at most $(c+2)n$ steps. In other words, algorithm $A'$ decides $L\_2$ in time $O(n)$.

But since $TIME(n) \subseteq SPACE(n)$, we can conclude that $L\_2 \in SPACE(n) \subsetneq SPACE(n^2)$. This contradicts the definition of $L\_2$. Thus, by contradiction we see that $L\_2 \not\in TIME(f(n))$.

> **Comments:**
> **username_1**: Nice! I wonder whether there are examples where both $f,g$ are elementary...  

---

### Answer by username_2 on 2018-02-18. Score: 1

In some sense yes, specifically as of right now we have that:

$\textbf{DTIME}(S(n)) \subseteq \textbf{SPACE}(S(n)) \subseteq \textbf{NSPACE}(S(n)) \subseteq \textbf{DTIME}(2^{O(S(n))})$

And also we know that $\textbf{PSPACE} \subsetneq \textbf{EXPSPACE}$
So that also implies $\textbf{P} \subsetneq \textbf{EXPSPACE}$.

Though we don't know what the specific relationships are for example between P and PSPACE, i.e. "is P a proper subset or are they the same?"

As for your question, one thing to note is that the space complexity is always upper bounded by time, since we cannot have that we use $g(n)$ space and $f(n)$ time when $f(n) = \textbf{o}(g(n))$, else it would mean the TM is accessing more cells without needing that many steps.

So for $\textbf{L}\_1$ to be in $f(n)$ time and $g(n)$ space would firstly imply that $f(n)$ is somewhat either equals to or larger than $g(n)$. And it'll be the case that it takes more than $g(n)$ space as long as the actual complexity is less than $f(n)$.

Then for $\textbf{L}\_2$ since it'll take more than $f(n)$ time, and $g(n)$ space, this is possible as long as we just let the actual time complexity be bigger than $f(n)$ (since the space complexity is already smaller anyway).

Then it'll depend on whether on $\textbf{L}\_2$ is in something like $\textbf{EXP}$ whereas $\textbf{L}\_1$ is in $\textbf{P}$ for us to conclusively say anything about their relative difficulty, since then we know $\textbf{P} \subsetneq \textbf{EXP}$.

Besides that as far as I know, we can't really tell, since the best we've done so far is the theorem that I firstly mentioned.

I'm sure you can craft up example for things that take greater time and less space as compared to other algorithms. I can't think of any examples of decision problems right now but consider something like dynamic programming, where you can decrease time complexity whilst increasing space complexity.

If you want to know more about that theorem you can try "Computational Complexity: A Modern Approach" by Sanjeev Arora and Boaz Barak
The theorem is mentioned on page 76.

> **Comments:**
> **username_0**: Thank you for your answer! However, I wasn't looking for results comparing the two hierarchies (I am already familiar with the results you cited). I was looking for languages for which the time hierarchy says $L_2$ is more complex but the space hierarchy says $L_1$ is more complex.  
> **username_2**: How about $L_1$ = { <s, t, G> : s is connected to t in directed graph G} and $L_2$ = { <array, d> : there exists a pair of integers in the array such that their sum is d}. $L_1$ can be decided in deterministic linear time and space, whereas $L_2$ can be decided in deterministic quadratic time and logarithmic space. So just set $f(n)$ = O(n) and $g(n)$ to be log(n) and I suppose this example should show there are languages that fit your example? It sure is an interesting question and I don't think I know more about this to give a more well informed answer.  
> **username_0**: Sadly $L_1\in NL$, and it is not known whether $L=NL$. If this were to be true, your example would be incorrect, since then $L_1$ would take logarithmic space.  
> **username_2**: Hmm yeah that's true. An oversight on my part  

---

