Questions tagged [constant-time]
12 questions
11
votes
2 answers
Do there exist "O(1)-complete" problems?
Many complexity classes have "complete" problems. Do complete problems exist for the complexity class of problems that can be solved in $O(1)$ time?
A complication is that this class depends on the model of computation; a problem can be solvable in…
Mike Battaglia
- 1,071
- 6
- 19
6
votes
3 answers
Is It Possible For a Data Structure to Have Constant Time Access/Insertion/Deletion?
I'm trying to come up with a data structure that could access, insert, and delete any element in constant time. I know that's pretty difficult, but I'm just doing it to invoke thought and understanding about computer science. However, I'm starting…
Badr B
- 207
- 2
- 10
6
votes
1 answer
Lower bound for finding majority element in a sorted array
Suppose $A$ is a sorted array with $n$ elements. I want to know whether we can determine if there are majority elements in $A$ with time complexity $O(1)$.
Recall that a majority element of $A$ is an element which appears over $n/2$ times in $A$.
I…
Paul
- 162
- 5
4
votes
3 answers
Element that occurs more than one third of the time in a sorted array - constant time?
Given a sorted array of positive integers that is guaranteed to have some unique entry that occupies more than $1/3$ of the entries, is there an algorithm to determine this entry in $O(1)$ time?
Some remarks:
(1) If we replaced $1/3$ with $1/2$,…
user165069
- 41
- 1
4
votes
0 answers
Are any known problems complete for $P$ under "$O(1)$ reductions?"
The usual many-one reduction involves Turing machines transforming an input, $w$, of some language to an input, $f(w)$, of some other language in polynomial time. (Where $w \in L_1 \iff f(w) \in L_2$).
But for $P$-completeness, logspace or NC…
Ank i zle
- 163
- 6
3
votes
1 answer
Simplest argument that language decidable in constant time cannot be $\mathsf{NP}$-hard?
My question is specifically about $\emptyset$, but more generally about any language that can be decided in (deterministic or nondeterministic doesn't really make a difference here) constant time. Obviously, $\emptyset$ cannot be $\mathsf{NP}$-hard…
G. Bach
- 2,019
- 1
- 17
- 27
2
votes
2 answers
Data structure with constant time operations
I need to use a data structure, implementable in C++, that can do basic operations, such as lookup, insertion and deletion, in constant time. I, however, also need to be able to find the maximum value in constant time.
This data structure should…
user35756
2
votes
1 answer
"Print 'em all game" for Turing machines
Suppose that we have a tape restricted to $n$ cells on binaryalphabet $\Sigma = \{0,1\}$ and initially filled with zeroes.
We want to build a Turing machine $M_n$ (or better a Linear Bounded Automata) that "prints" all the $2^n$ numbers on the…
Vor
- 12,743
- 1
- 31
- 62
2
votes
2 answers
Sorted list of counters in constant time
Summary.
A data structure maintains in constant time a sorted list of counter values, for a dynamic set of counters. I am interested in references using this structure, and in possible improvements.
Problem and motivation.
Consider a set of…
Matthieu Latapy
- 685
- 4
- 20
1
vote
1 answer
Finding the Range of Solutions for KSum Variation
Preface
I asked a question before where I was looking to understand the complexity class of the following problem:
Given a range of integers $\{a,a+1,...,b-1,b\}$, find a subset of size $k$ such that the sum is equal to $s$.
I had found a $O(k)$…
tkellehe
- 157
- 6
0
votes
1 answer
What are some constant time operations?
I know that some operations are definitely constant time, such as accessing an item in a list, however there are other operations that are assumed constant time sometimes, but non-constant other times, such as multiplication.
So if we were to deal…
wjmccann
- 579
- 5
- 15
0
votes
2 answers
Interview question (constant-time algorithm, ILP)
A juice machine has three buttons small, medium large. Each size adds an amount of juice in a range to the cup. Eg small might add from 10-20 mL, medium from 30-35 mL, large from 40-50 mL. The exact numbers are relatively small (0-1000), integral,…
s n
- 11
- 2