Most Popular
1500 questions
45
votes
4 answers
What are common techniques for reducing problems to each other?
In computability and complexity theory (and maybe other fields), reductions are ubiquitous. There are many kinds, but the principle remains the same: show that one problem $L_1$ is at least as hard as some other problem $L_2$ by mapping instances…

Raphael
- 72,336
- 29
- 179
- 389
45
votes
2 answers
How to show that a function is not computable? How to show a language is not computably enumerable?
I know that there exists a Turing Machine, if a function is computable. Then how to show that the function is not computable or there aren't any Turing Machine for that. Is there anything like a Pumping lemma?
Similarly, how can we show a language…

user5507
- 2,191
- 4
- 24
- 41
44
votes
4 answers
Are there NP problems, not in P and not NP Complete?
Are there any known problems in $\mathsf{NP}$ (and not in $\mathsf{P}$) that aren't $\mathsf{NP}$ Complete? My understanding is that there are no currently known problems where this is the case, but it hasn't been ruled out as a possibility.
If…

vpiTriumph
- 563
- 1
- 4
- 7
44
votes
2 answers
Determining capabilities of a min-heap (or other exotic) state machines
See the end of this post for some clarification on the definition(s) of min-heap automata.
One can imagine using a variety of data structures for storing information for use by state machines. For instance, push-down automata store information in a…

Patrick87
- 12,824
- 1
- 44
- 76
43
votes
3 answers
Deciding on Sub-Problems for Dynamic Programming
I have used the technique of dynamic programming multiple times however today a friend asked me how I go about defining my sub-problems, I realized I had no way of providing an objective formal answer. How do you formally define a sub-problem for a…

daniel gratzer
- 1,480
- 1
- 13
- 22
43
votes
9 answers
Why are some programming languages Turing complete but lack some abilities of other languages?
I came across an odd problem when writing an interpreter that (should) hooks to external programs/functions: Functions in 'C' and 'C++' can't hook variadic functions, e.g. I can't make a function that calls 'printf' with the exact same arguments…

Mr. Minty Fresh
- 592
- 1
- 5
- 11
43
votes
1 answer
Do you get DFS if you change the queue to a stack in a BFS implementation?
Here is the standard pseudocode for breadth first search:
{ seen(x) is false for all x at this point }
push(q, x0)
seen(x0) := true
while (!empty(q))
x := pop(q)
visit(x)
for each y reachable from x by one edge
if not seen(y)
push(q,…

rgrig
- 1,336
- 1
- 11
- 15
43
votes
4 answers
Worst case $O(n \ln n)$ in place stable sort?
I am having trouble finding good resources that give a worst case $O(n \ln n)$ in place stable sorting algorithm. Does anyone know of any good resources?
Just a reminder, in place means it uses the array passed in and the sorting algorithm is only…

user834
- 849
- 1
- 8
- 11
43
votes
6 answers
Why and how is a quantum computer faster than a regular computer?
I'm currently reading a book (and a lot of wikipedia) about quantum physics and I've yet to understand how a quantum computer can be faster than the computers we have today.
How can a quantum computer solve a problem in sub-exponential time that a…

Tom
- 657
- 2
- 8
- 10
43
votes
2 answers
Efficient data structures for building a fast spell checker
I'm trying to write a spell-checker which should work with a pretty large dictionary. I really want an efficient way to index my dictionary data to be used using a Damerau-Levenshtein distance to determine which words are closest to the misspelled…

Charles Menguy
- 1,183
- 1
- 10
- 12
43
votes
0 answers
Is there a regular tree language in which the average height of a tree of size $n$ is neither $\Theta(n)$ nor $\Theta(\sqrt{n})$?
We define a regular tree language as in the book TATA: It is the set of trees accepted by a non-deterministic finite tree automaton (Chapter 1) or, equivalently, the set of trees generated by a regular tree grammar (Chapter 2). Both formalisms hold…

john_leo
- 1,891
- 14
- 25
42
votes
9 answers
Understanding serialization
I am a software engineer and after a discussion with some colleagues, I realized I do not have a good grasp of the concept serialization. As I understand, serialization is the process of converting some entity, such as an object in OOP, to a…

ddcz
- 523
- 1
- 4
- 4
42
votes
5 answers
What exactly (and precisely) is "hash?"
I have heard the word "hash" being used in different contexts (all within the world of computing) with different meanings. For example, in the book Learn Python the Hard Way, in the chapter on dictionaries it is said "Python calls them "dicts."…

Basil Ajith
- 591
- 1
- 5
- 9
42
votes
1 answer
Imagine a red-black tree. Is there always a sequence of insertions and deletions that creates it?
Let's assume the following definition of a red-black tree:
It is a binary search tree.
Each node is colored either red or black. The root is black.
Two nodes connected by an edge cannot be red at the same time.
Here should be a good definition of a…

alisianoi
- 419
- 3
- 10
42
votes
2 answers
Why do we believe that PSPACE ≠ EXPTIME?
I'm having trouble intuitively understanding why PSPACE is generally believed to be different from EXPTIME. If PSPACE is the set of problems solvable in space polynomial in the input size $f(n)$, then how can there be a class of problems that…

user25876
- 423
- 1
- 4
- 5