Asymptotic analyses of the space needed to run algorithms.
Questions tagged [space-complexity]
531 questions
32
votes
1 answer
Does space complexity analysis usually include output space?
Since most examples of complexity analysis I've seen involve functions that return either nothing (e.g. in-place sort) or a single value (e.g. computation, lookup), I haven't been able to figure this out just by reading examples.
If a function…
Kevin Kibler
- 423
- 1
- 4
- 7
16
votes
2 answers
Time-space tradeoff for missing element problem
Here is a well-known problem.
Given an array $A[1\dots n]$ of positive integers, output the smallest positive integer not in the array.
The problem can be solved in $O(n)$ space and time: read the array, keep track in $O(n)$ space whether…
sdcvvc
- 3,511
- 19
- 28
14
votes
1 answer
Direct reduction from $st\text{-}non\text{-}connectivity$ to $st\text{-}connectivity$
We know that $st\text{-}non\text{-}connectivity$ is in $\mathsf{NL}$ by Immerman–Szelepcsényi theorem theorem and since $st\text{-}connectivity$ is $\mathsf{NL\text{-}hard}$ therefore $st\text{-}non\text{-}connectivity$ is many-one log-space…
Kaveh
- 22,661
- 4
- 53
- 113
14
votes
0 answers
What can be proven regarding the differences in power between unary ECMAScript regex functions and primitive recursive functions?
In 2014, inspired by Regex Golf, I started exploring, along with a mathematician going by the name teukon, what could be done in the unary domain in ECMAScript regex that went significantly beyond matching primes and powers of 2 (both of which were…
Deadcode
- 241
- 1
- 5
13
votes
7 answers
How to check if two strings are permutations of each other using O(1) additional space?
Given two strings how can you check if they are a permutation of each other using O(1) space? Modifying the strings is not allowed in any way.
Note: O(1) space in relation to both the string length AND the size of the alphabet.
Teodor Dyakov
- 1,341
- 1
- 13
- 22
13
votes
1 answer
Algorithms with O(sqrt(N)) SPACE complexity?
Are there any known algorithms for formulated problems that require a SPACE complexity of O(sqrt(N))? I know that algorithms with that big-O time complexity exist.
vawd_gandi
- 131
- 3
12
votes
1 answer
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!
gdiazc
- 221
- 1
- 4
11
votes
1 answer
What does sublinear space mean for Turing machines?
The problem of deciding whether an input is a palindrome or not has been proved to require $\Omega(\log n)$ space on a Turing machine. However, even storing the input takes space $n$ so doesn't that mean that all Turing machines require space…
jsguy
- 639
- 8
- 21
11
votes
1 answer
Bound on space for selection algorithm?
There is a well known worst case $O(n)$ selection algorithm to find the $k$'th largest element in an array of integers. It uses a median-of-medians approach to find a good enough pivot, partitions the input array in place and then recursively…
user834
- 849
- 1
- 8
- 11
11
votes
2 answers
What's the complexity of Spearman's rank correlation coefficient computation?
I've been studying the Spearman's rank correlation coefficient
$\qquad \displaystyle \rho = \frac{\sum_i(x_i-\bar{x})(y_i-\bar{y})}{\sqrt{\sum_i (x_i-\bar{x})^2 \sum_i(y_i-\bar{y})^2}}$.
for two lists $x_1, \dots, x_n$ and $y_1, \dots, y_n$. What's…
DavideChicco.it
- 211
- 2
- 4
11
votes
2 answers
Has there been any more progress on P vs. PSPACE compared to P vs. NP?
I understand this is a slightly vague question, but there are results for P vs. NP, such as the question cannot be easily resolved using oracles. Are there any results like this which have been shown for P vs. NP but have not been shown for P vs…
user2566092
- 1,741
- 10
- 18
11
votes
5 answers
Does an algorithm's space complexity include input?
Consider the Kadane's algorithm for finding maximum subarray within an array:
def max_subarray(numbers):
"""Find the largest sum of any contiguous subarray."""
best_sum = 0
current_sum = 0
for x in numbers:
current_sum =…
Eugene Yarmash
- 275
- 3
- 8
11
votes
1 answer
What is a compact way to represent a partition of a set?
There exist efficient data
structures for representing set
partitions. These data structures have good time complexities for operations
like Union and Find, but they are not particularly space-efficient.
What is a space-efficient way to represent a…
cberzan
- 213
- 1
- 5
10
votes
4 answers
A language in NSPACE(O(n)) and very likely not in DSPACE(O(n))
Actually I found that the set of context-sensitive Languages, $\mathbf{CSL}$ ($\mathbf{=NSPACE(O(n)) = LBA}$ accepted languages) are not so widely discussed as $\mathbf{REG}$ (regular languages) or $\mathbf{CFL}$ (context-free languages).
And also…
rl1
- 243
- 1
- 6
10
votes
1 answer
Proving that $\mathrm{SPACE}(o(\log\log n)) = \mathrm{SPACE}(O(1))$?
It is known that $\mathrm{SPACE}(o(\log \log n)) = \mathrm{SPACE}(O(1))$ (see e.g. these lecture notes by Christian Scheideler).
One inclusion is trivial, so I'm trying to show that $\mathrm{SPACE}(o(\log \log n)) \subseteq \mathrm{SPACE}(O(1))$ as…
user35837