Most Popular

1500 questions
86
votes
6 answers

How can we assume that basic operations on numbers take constant time?

Normally in algorithms we do not care about comparison, addition, or subtraction of numbers -- we assume they run in time $O(1)$. For example, we assume this when we say that comparison-based sorting is $O(n\log n)$, but when numbers are too big to…
user742
84
votes
6 answers

Formal program verification in practice

As a software engineer, I write a lot of code for industrial products. Relatively complicated stuff with classes, threads, some design efforts, but also some compromises for performance. I do a lot of testing, and I am tired of testing, so I got…
Frank
  • 1,612
  • 1
  • 13
  • 15
80
votes
3 answers

How do computers keep track of time?

How are computers able to tell the correct time and date every time? Whenever I close the computer (shut it down) all connections and processes inside stop. How is it that when I open the computer again it tells the exact correct time? Does the…
Soham
  • 937
  • 1
  • 7
  • 8
80
votes
3 answers

Express boolean logic operations in zero-one integer linear programming (ILP)

I have an integer linear program (ILP) with some variables $x_i$ that are intended to represent boolean values. The $x_i$'s are constrained to be integers and to hold either 0 or 1 ($0 \le x_i \le 1$). I want to express boolean operations on these…
D.W.
  • 159,275
  • 20
  • 227
  • 470
79
votes
2 answers

What does the "Lambda" in "Lambda calculus" stand for?

I've been reading about Lambda calculus recently but strangely I can't find an explanation for why it is called "Lambda" or where the expression comes from. Can anyone explain the origins of the term?
Klangen
  • 1,100
  • 8
  • 15
79
votes
2 answers

What is coinduction?

I've heard of (structural) induction. It allows you to build up finite structures from smaller ones and gives you proof principles for reasoning about such structures. The idea is clear enough. But what about coinduction? How does it work? How can…
Dave Clarke
  • 20,205
  • 4
  • 68
  • 113
78
votes
9 answers

Why is addition as fast as bit-wise operations in modern processors?

I know that bit-wise operations are so fast on modern processors, because they can operate on 32 or 64 bits on parallel, so bit-wise operations take only one clock cycle. However addition is a complex operation that consists of at least one and…
Teodor Dyakov
  • 1,331
  • 1
  • 13
  • 22
78
votes
8 answers

Floyd's Cycle detection algorithm | Determining the starting point of cycle

I am seeking help understanding Floyd's cycle detection algorithm. I have gone through the explanation on wikipedia (http://en.wikipedia.org/wiki/Cycle_detection#Tortoise_and_hare) I can see how the algorithm detects cycle in O(n) time. However, I…
Anurag Kapur
  • 883
  • 1
  • 7
  • 8
78
votes
5 answers

What important/crucial real-world applications use blockchain?

As part of some blockchain-related research I am currently undertaking, the notion of using blockchains for a variety of real-world applications are thrown about loosely. Therefore, I propose the following questions: What important/crucial…
rshah
  • 863
  • 1
  • 7
  • 12
77
votes
6 answers

Why is the Turing Machine a popular model of computation?

I am a CS undergraduate. I understand how Turing came up with his abstract machine (modeling a person doing a computation), but it seems to me to be an awkward, inelegant abstraction. Why do we consider a "tape", and a machine head writing symbols,…
Alex
  • 903
  • 1
  • 7
  • 5
77
votes
4 answers

Dependent types vs refinement types

Could somebody explain the difference between dependent types and refinement types? As I understand it, a refinement type contains all values of a type fulfilling a predicate. Is there a feature of dependent types which distinguishes them? If it…
Joey Eremondi
  • 29,754
  • 5
  • 64
  • 121
76
votes
4 answers

What is tail recursion?

I know the general concept of recursion. I came across the concept of tail recursion while studying the quicksort algorithm. In this video of quick sort algorithm from MIT at 18:30 seconds the professor says that this is a tail recursive…
Geek
  • 1,191
  • 1
  • 10
  • 12
76
votes
1 answer

Language theoretic comparison of LL and LR grammars

People often say that LR(k) parsers are more powerful than LL(k) parsers. These statements are vague most of the time; in particular, should we compare the classes for a fixed $k$ or the union over all $k$? So how is the situation really? In…
Raphael
  • 72,336
  • 29
  • 179
  • 389
76
votes
9 answers

What properties of a programming language make compilation impossible?

Question: "Certain properties of a programming language may require that the only way to get the code written in it be executed is by interpretation. In other words, compilation to a native machine code of a traditional CPU is not possible. What are…
74
votes
4 answers

(When) is hash table lookup O(1)?

It is often said that hash table lookup operates in constant time: you compute the hash value, which gives you an index for an array lookup. Yet this ignores collisions; in the worst case, every item happens to land in the same bucket and the lookup…
Gilles 'SO- stop being evil'
  • 43,613
  • 8
  • 118
  • 182