Most Popular
1500 questions
65
votes
7 answers
Is legislation NP-complete?
I would like to know if there has been any work relating legal code to complexity. In particular, suppose we have the decision problem "Given this law book and this particular set of circumstances, is the defendant guilty?" What complexity class…

Stand with Gaza
- 1,234
- 1
- 9
- 15
64
votes
8 answers
Algorithmic intuition for logarithmic complexity
I believe I have a reasonable grasp of complexities like $\mathcal{O}(1)$, $\Theta(n)$ and $\Theta(n^2)$.
In terms of a list, $\mathcal{O}(1)$ is a constant lookup, so it's just getting the head of the list.
$\Theta(n)$ is where I'd walk the entire…

Khanzor
- 1,451
- 1
- 13
- 11
63
votes
10 answers
What is a safe programming language?
Safe programming languages (PL) are gaining popularity. What is the formal definition of safe PL? For example, C is not safe, but Java is safe. I suspect that the property “safe” should be applied to a PL implementation rather than to the PL itself.…

beroal
- 781
- 1
- 5
- 12
63
votes
6 answers
If everyone believes P ≠ NP, why is everyone sceptical of proof attempts for P ≠ NP?
Many seem to believe that $P\ne NP$, but many also believe it to be very unlikely that this will ever be proven. Is there not some inconsistency to this? If you hold that such a proof is unlikely, then you should also believe that sound arguments…

pafnuti
- 729
- 1
- 5
- 7
63
votes
14 answers
How can I explain to my parents that I study programming languages?
I am currently finishing my MSc in computer science. I am interested in programming languages, especially in type systems. I got interested in research in this field and next semester I will start a PhD on the subject.
Now here is the real question:…

effeffe
- 741
- 1
- 5
- 10
63
votes
4 answers
Why are Red-Black trees so popular?
It seems that everywhere I look, data structures are being implemented using red-black trees (std::set in C++, SortedDictionary in C#, etc.)
Having just covered (a,b), red-black & AVL trees in my algorithms class, here's what I got out (also from…

Jakub Arnold
- 867
- 1
- 7
- 9
62
votes
7 answers
Is a Turing Machine "by definition" the most powerful machine?
I agree that a Turing Machine can do "all possible mathematical problems". But that is because it is just a machine representation of an algorithm: first do this, then do that, finally output that.
I mean anything that is solvable can be…

Sounak Bhattacharya
- 677
- 1
- 6
- 5
62
votes
6 answers
Why do we not combine random number generators?
There are many applications where a pseudo random number generator is used. So people implement one that they think is great only to find later that it's flawed. Something like this happened with the Javascript random number generator recently. …

Paul Uszak
- 1,602
- 1
- 13
- 21
61
votes
5 answers
Is zero allowed as an edge's weight, in a weighted graph?
I am trying to write a script that generates random graphs and I need to know if an edge in a weighted graph can have the 0 value.
actually it makes sense that 0 could be used as an edge's weight, but I've been working with graphs in last few days…

Taxellool
- 729
- 1
- 5
- 6
61
votes
8 answers
Is Morse code without spaces uniquely decipherable?
Are all Morse code strings uniquely decipherable? Without the spaces,
......-...-..---.-----.-..-..-..
could be Hello World but perhaps the first letter is a 5 -- in fact it looks very unlikely an arbitrary sequence of dots and dashes should have…

john mangual
- 1,941
- 1
- 21
- 26
60
votes
3 answers
What exactly is polynomial time?
I'm trying to understand algorithm complexity, and a lot of algorithms are classified as polynomial. I couldn't find an exact definition anywhere. I assume it is the complexity that is not exponential.
Do linear/constant/quadratic complexities…

Oleksiy
- 703
- 1
- 5
- 6
59
votes
4 answers
What exactly is the semantic difference between set and type?
EDIT: I've now asked a similar question about the difference between categories and sets.
Every time I read about type theory (which admittedly is rather informal), I can't really understand how it differs from set theory, concretely.
I understand…

user56834
- 3,722
- 4
- 18
- 32
59
votes
13 answers
Is C actually Turing-complete?
I was trying to explain to someone that C is Turing-complete, and realized that I don't actually know if it is, indeed, technically Turing-complete. (C as in the abstract semantics, not as in an actual implementation.)
The "obvious" answer…

TLW
- 1,414
- 1
- 9
- 15
59
votes
3 answers
Why is binary search faster than ternary search?
Searching an array of $N$ elements using binary search takes, in the worst case $\log_2 N$ iterations because, at each step we trim half of our search space.
If, instead, we used 'ternary search', we'd cut away two-thirds of our search space at…

The Mean Square
- 768
- 1
- 5
- 14
59
votes
7 answers
Why does a processor have 32 registers?
I've always wondered why processors stopped at 32 registers. It's by far the fastest piece of the machine, why not just make bigger processors with more registers? Wouldn't that mean less going to the RAM?

Matt Capone
- 711
- 1
- 6
- 5