Most Popular
1500 questions
73
votes
4 answers
Find median of unsorted array in $O(n)$ time
To find the median of an unsorted array, we can make a min-heap in $O(n\log n)$ time for $n$ elements, and then we can extract one by one $n/2$ elements to get the median. But this approach would take $O(n \log n)$ time.
Can we do the same by some…

Luv
- 851
- 1
- 7
- 5
72
votes
4 answers
What is the novelty in MapReduce?
A few years ago, MapReduce was hailed as revolution of distributed programming. There have also been critics but by and large there was an enthusiastic hype. It even got patented! [1]
The name is reminiscent of map and reduce in functional…

Raphael
- 72,336
- 29
- 179
- 389
72
votes
10 answers
Minimum spanning tree vs Shortest path
What is the difference between minimum spanning tree algorithm and a shortest path algorithm?
In my data structures class we covered two minimum spanning tree algorithms (Prim's and Kruskal's) and one shortest path algorithm (Dijkstra's).
Minimum…

flashburn
- 1,223
- 1
- 12
- 22
71
votes
6 answers
Are there minimum criteria for a programming language being Turing complete?
Does there exist a set of programming language constructs in a programming language in order for it to be considered Turing Complete?
From what I can tell from wikipedia, the language needs to support recursion, or, seemingly, must be able to run…

Khanzor
- 1,451
- 1
- 13
- 11
69
votes
3 answers
Knapsack problem -- NP-complete despite dynamic programming solution?
Knapsack problems are easily solved by dynamic programming. Dynamic programming runs in polynomial time; that is why we do it, right?
I have read it is actually an NP-complete problem, though, which would mean that solving the problem in polynomial…

Strin
- 1,505
- 1
- 11
- 16
69
votes
10 answers
Can a dynamic language like Ruby/Python reach C/C++ like performance?
I wonder if it is possible to build compilers for dynamic languages like Ruby to have similar and comparable performance to C/C++? From what I understand about compilers, take Ruby for instance, compiling Ruby code can't ever be efficient because…

Ichiro
- 815
- 1
- 7
- 5
69
votes
9 answers
Are there any problems that get easier as they increase in size?
This may be a ridiculous question, but is it possible to have a problem that actually gets easier as the inputs grow in size? I doubt any practical problems are like this, but maybe we can invent a degenerate problem that has this property. For…

dsaxton
- 923
- 6
- 9
66
votes
12 answers
Why don't compilers automatically insert deallocations?
In languages like C, the programmer is expected to insert calls to free. Why doesn't the compiler do this automatically? Humans do it in a reasonable amount of time(ignoring bugs), so it is not impossible.
EDIT: For future reference, here is another…

Milton Silva
- 815
- 1
- 6
- 8
66
votes
3 answers
In-place algorithm for interleaving an array
You are given an array of $2n$ elements
$$a_1, a_2, \dots, a_n, b_1, b_2, \dots b_n$$
The task is to interleave the array, using an in-place algorithm such that the resulting array looks like
$$b_1, a_1, b_2, a_2, \dots , b_n, a_n$$
If the in-place…

Aryabhata
- 6,261
- 2
- 35
- 46
66
votes
2 answers
What happens to the cache contents on a context switch?
In a multicore processor, what happens to the contents of a core's cache (say L1) when a context switch occurs on that cache?
Is the behaviour dependent on the architecture or is it a general behaviour followed by all chip manufacturers?

Ankit
- 1,327
- 2
- 14
- 18
65
votes
2 answers
Are there subexponential-time algorithms for NP-complete problems?
Are there NP-complete problems which have proven subexponential-time algorithms?
I am asking for the general case inputs, I am not talking about tractable special cases here.
By sub-exponential, I mean an order of growth above polynomials, but…

ksb
- 781
- 1
- 6
- 5
65
votes
9 answers
What would be the real-world implications of a constructive $P=NP$ proof?
I have a high-level understanding of the $P=NP$ problem and I understand that if it were absolutely "proven" to be true with a provided solution, it would open the door for solving numerous problems within the realm of computer science.
My question…

RLH
- 829
- 1
- 8
- 10
65
votes
11 answers
Human computing power: Can humans decide the halting problem on Turing Machines?
We know the halting problem (on Turing Machines) is undecidable for Turing Machines. Is there some research into how well the human mind can deal with this problem, possibly aided by Turing Machines or general purpose computers?
Note: Obviously, in…

bitmask
- 1,755
- 2
- 16
- 20
65
votes
8 answers
What is a the fastest sorting algorithm for an array of integers?
I have come across many sorting algorithms during my high school studies. However, I never know which is the fastest (for a random array of integers). So my questions are:
Which is the fastest currently known sorting algorithm?
Theoretically, is it…

gen
- 991
- 1
- 8
- 15
65
votes
8 answers
Distributed vs parallel computing
I often hear people talking about parallel computing and distributed computing, but I'm under the impression that there is no clear boundary between the 2, and people tend to confuse that pretty easily, while I believe it is very…

Charles Menguy
- 1,183
- 1
- 10
- 12