Most Popular
1500 questions
111
votes
9 answers
How/when is calculus used in Computer Science?
Many computer science programs require two or three calculus classes.
I'm wondering, how and when is calculus used in computer science? The CS content of a degree in computer science tends to focus on algorithms, operating systems, data structures,…

Victor
- 1,289
- 2
- 9
- 8
110
votes
2 answers
Quicksort Partitioning: Hoare vs. Lomuto
There are two quicksort partition methods mentioned in Cormen:
(the argument A is the array, and [p, r] is the range, inclusive, to perform the partition on. The returned value is the index to the pivot after the partition.)
Hoare-Partition(A, p,…

Robert S. Barnes
- 2,911
- 5
- 24
- 24
107
votes
7 answers
Why is it best to use a prime number as a mod in a hashing function?
If I have a list of key values from 1 to 100 and I want to organize them in an array of 11 buckets, I've been taught to form a mod function
$$ H = k \bmod \ 11$$
Now all the values will be placed one after another in 9 rows. For example, in the…

CodyBugstein
- 2,957
- 10
- 30
- 45
106
votes
5 answers
How not to solve P=NP?
There are lots of attempts at proving either $\mathsf{P} = \mathsf{NP} $ or $\mathsf{P} \neq \mathsf{NP}$, and naturally many people think about the question, having ideas for proving either direction.
I know that there are approaches that have been…

Raphael
- 72,336
- 29
- 179
- 389
103
votes
7 answers
Why is deep learning hyped despite bad VC dimension?
The Vapnik–Chervonenkis (VC)-dimension formula for neural networks ranges from $O(E)$ to $O(E^2)$, with $O(E^2V^2)$ in the worst case, where $E$ is the number of edges and $V$ is the number of nodes. The number of training samples needed to have a…

yters
- 1,417
- 2
- 12
- 21
101
votes
3 answers
How does one know which notation of time complexity analysis to use?
In most introductory algorithm classes, notations like $O$ (Big O) and $\Theta$ are introduced, and a student would typically learn to use one of these to find the time complexity.
However, there are other notations, such as $o$, $\Omega$ and…

Jack H
- 1,323
- 3
- 11
- 11
101
votes
5 answers
What are the reasons to learn different algorithms / data structures serving the same purpose?
I have been wondering about this question since I was an undergraduate student.
It is a general question but I will elaborate with examples below.
I have seen a lot of algorithms - for example, for maximum flow problems, I know around 3 algorithms…

shole
- 1,200
- 1
- 9
- 10
98
votes
5 answers
How to prove that a language is not context-free?
We learned about the class of context-free languages $\mathrm{CFL}$. It is characterised by both context-free grammars and pushdown automata so it is easy to show that a given language is context-free.
How do I show the opposite, though? My TA has…

Raphael
- 72,336
- 29
- 179
- 389
97
votes
11 answers
Solving or approximating recurrence relations for sequences of numbers
In computer science, we have often have to solve recurrence relations, that is find a closed form for a recursively defined sequence of numbers. When considering runtimes, we are often interested mainly in the sequence's asymptotic growth.
Examples…

Raphael
- 72,336
- 29
- 179
- 389
97
votes
10 answers
How to prove that a language is not regular?
We learned about the class of regular languages $\mathrm{REG}$. It is characterised by any one concept among regular expressions, finite automata and left-linear grammars, so it is easy to show that a given language is regular.
How do I show the…

Raphael
- 72,336
- 29
- 179
- 389
95
votes
13 answers
What are GPUs bad at?
I understand that GPUs are generally used to do LOTS of calculations in parallel. I understand why we would want to parallelize processes in order to speed things up. However, GPUs aren't always better than CPUs, as far as I know.
What kinds of…

ChocolateOverflow
- 1,111
- 1
- 7
- 12
93
votes
7 answers
Why are some programming languages "faster" or "slower" than others?
I have noticed that some applications or algorithms that are built on a programming language, say C++/Rust run faster or snappier than those built on say, Java/Node.js, running on the same machine. I have a few question regarding this:
Why does…

evil_potato
- 1,362
- 2
- 12
- 11
92
votes
6 answers
Is there any concrete relation between Gödel's incompleteness theorem, the halting problem and universal Turing machines?
I've always thought vaguely that the answer to the above question was affirmative along the following lines. Gödel's incompleteness theorem and the undecidability of the halting problem both being negative results about decidability and established…

Marc van Leeuwen
- 1,023
- 1
- 8
- 13
90
votes
11 answers
Why is the unit of image size not Pixel²?
If you calculate the area of a rectangle, you just multiply the height and the width and get back the unit squared.
Example:
5cm * 10cm = 50cm²
In contrast, if you calculate the size of an image, you also multiply the height and the width, but you…

JFFIGK
- 1,017
- 1
- 8
- 11
86
votes
8 answers
Graph searching: Breadth-first vs. depth-first
When searching graphs, there are two easy algorithms: breadth-first and depth-first (Usually done by adding all adjactent graph nodes to a queue (breadth-first) or stack (depth-first)).
Now, are there any advantages of one over another?
The ones I…

malexmave
- 985
- 1
- 7
- 9