What is Big and O in Big O notation? I've read the definitions and it doesn't tell what is O pronounced as 'oh'. For example - I understand that O(n) is complexity of a linear algorithm where n could be the number of operations. but what is an O?
Well, my guess would be order, which coincides with wikipedia.
Edit: (my own (any improvements appreciated)) translation from the German wikipedia article
"Big" means "capital", and "O" means order, as in "order of complexity". So named because of the convention of writing "order of complexity" as O(f(x)), e.g., with a capital letter 'O', or a 'Big O'. Nobody talks about it much because 'everyone' understands what it means, and understanding it doesn't really help you understand complexity analysis.
For an understanding of complexity analysis, I think the link posted by topgun_ivard is a good place to start. A good introductory textbook covering data structures or algorithms might also help.
|show 2 more comments|
O stands for order.
It was originally introduced by the German mathematician Paul Bachmann in the second volume of his books on number theory Die Analytische Zahlentheorie, published in 1894 (p. 401). He notes, after a formula where he first uses the notation:
In contrast with what others have said, nothing in his text indicates that this is in fact a Greek capital omikron. He uses plenty of both Greek and Latin characters, so there isn't really any way to tell. Given his continued use of "Ordnung n log n" etc. in the text it's clear that it stands for "Ordnung" (German for "order" if there was any doubt) in any case, but that could still leave open the use of a fancy Greek O.
However, the origin of the omikron is more likely a retronym due to Donald Knuth who introduced the symbols omega (Ω) and theta (Θ) for related concepts in his paper Big Omicron and Big Omega and Big Theta, or possibly Hardy and Littlewood who introduced an omega symbol earlier.
I like this article, hoping you would find it useful too!
Quoting a section from the article:
Big O is often misused. Big O or Big Oh is actually short for Big Omicron. It represents the upper bound of asymptotic complexity. So if an algorithm is O(n log n) there exists a constant c such that the upper bound is cn log n.
Θ(n log n) (Big Theta) is more tightly bound than that. Such an algorithm means there exists two constants c1 and c2 such that c1n log n < f(n) < c2n log n.
Ω(n log n) (Big Omega) says that the algorithm has a lower bound of cn log n.
There are others but these are the most common and Big O is the most common of all. Such a distinction is typically unimportant but it is worth noting. The correct notation is the correct notation, after all.
What is Big O?
Big O notation seeks to describe the relative complexity of an algorithm by reducing the growth rate to the key factors when the key factor tends towards infinity. For this reason, you will often hear the phrase asymptotic complexity. In doing so, all other factors are ignored. It is a relative representation of complexity.
What Isn’t Big O?
Big O isn’t a performance test of an algorithm. It is also notional or abstract in that it tends to ignore other factors. Sorting algorithm complexity is typically reduced to the number of elements being sorted as being the key factor. This is fine but it doesn’t take into account issues such as:
Memory Usage: one algorithm might use much more memory than another. Depending on the situation this could be anything from completely irrelevant to critical; Cost of Comparison: It may be that comparing elements is really expensive, which will potentially change any real-world comparison between algorithms; Cost of Moving Elements: copying elements is typically cheap but this isn’t necessarily the case; etc.
|show 4 more comments|
"f(x) is big-oh of g(x)"
It is a mathematical way to predict the growth of functions.
Let f and g be functions from the set of integers or the set or real numbers to the set of real numbers. We say that f(x) is O(g(x)) if there are constants C and k such that |f(x)| <= C|g(x)| wherever x > k.
You would read this as "f(x) is big-oh of g(x)"
The big-O is sometimes called a Landau symbol after the German mathematician Edmund Landau. I don't think it stands for anything beyond that. You also have the similar big-Omega and big-Theta notations. The symbols are as arbitrary as always using theta to denote the angles in your triangles was in your high-school Planar Geometry class.
Correction @back2dos has provided a satisfactory explanation for the O as referring to order. Great Job. See his answer.
Donald Knuth applied it to studying the complexity of computer programs.
If you want to find the reason the notation was used, you should read
"Analytische Zahlentheorie" by Paul Bachmann from 1892
EDIT: Turns out that I am wrong. Nevertheless, maybe this helps someone keep their symbols straight, so I'm not going to delete it.
Actually, it's not the Latin letter Oh, it's the Greek letter Omicron. Unfortunately, those two have the exact same glyph, so, over time, the original version got corrupted, and now it is just Oh.
The choice of symbol doesn't actually have any particular meaning, it was chosen as a mnemonic device:
That's it. There's no real meaning to it, it's just a play on words, if you will, to help you remember the semantics more easily.
UPDATE: Attempting to clean up my answer and be more accurate
Big O notation is a way to characterize functions according to there growth rates. The O stands for order (first order being n second order being n-squared etc). And if I am not mistaken this would be the worst case scenario for a methods runtime(or storage) given N elements. The larger the order the worst the method performs.
This answer should be slightly more correct than my first attempt :)