Sometimes I see Θ(n) with the strange Θ symbol with something in the middle of it, and sometimes just O(n). Is it just laziness of typing because nobody knows how to type this symbol, or does it mean something different?

10It's not obvious, but this question is a duplicate of this one stackoverflow.com/questions/464078/… from yesterday.– Bill the LizardJan 23 '09 at 0:03

Possible duplicate of Difference between lower bound and tight bound?– Damian PavlicaMar 29 '18 at 13:03
Short explanation:
If an algorithm is of Θ(g(n)), it means that the running time of the algorithm as n (input size) gets larger is proportional to g(n).
If an algorithm is of O(g(n)), it means that the running time of the algorithm as n gets larger is at most proportional to g(n).
Normally, even when people talk about O(g(n)) they actually mean Θ(g(n)) but technically, there is a difference.
More technically:
O(n) represents upper bound. Θ(n) means tight bound. Ω(n) represents lower bound.
f(x) = Θ(g(x)) iff f(x) = O(g(x)) and f(x) = Ω(g(x))
Basically when we say an algorithm is of O(n), it's also O(n^{2}), O(n^{1000000}), O(2^{n}), ... but a Θ(n) algorithm is not Θ(n^{2}).
In fact, since f(n) = Θ(g(n)) means for sufficiently large values of n, f(n) can be bound within c_{1}g(n) and c_{2}g(n) for some values of c_{1} and c_{2}, i.e. the growth rate of f is asymptotically equal to g: g can be a lower bound and and an upper bound of f. This directly implies f can be a lower bound and an upper bound of g as well. Consequently,
f(x) = Θ(g(x)) iff g(x) = Θ(f(x))
Similarly, to show f(n) = Θ(g(n)), it's enough to show g is an upper bound of f (i.e. f(n) = O(g(n))) and f is a lower bound of g (i.e. f(n) = Ω(g(n)) which is the exact same thing as g(n) = O(f(n))). Concisely,
f(x) = Θ(g(x)) iff f(x) = O(g(x)) and g(x) = O(f(x))
There are also littleoh and littleomega (ω
) notations representing loose upper and loose lower bounds of a function.
To summarize:
f(x) = O(g(x))
(bigoh) means that the growth rate off(x)
is asymptotically less than or equal to to the growth rate ofg(x)
.
f(x) = Ω(g(x))
(bigomega) means that the growth rate off(x)
is asymptotically greater than or equal to the growth rate ofg(x)
f(x) = o(g(x))
(littleoh) means that the growth rate off(x)
is asymptotically less than the growth rate ofg(x)
.
f(x) = ω(g(x))
(littleomega) means that the growth rate off(x)
is asymptotically greater than the growth rate ofg(x)
f(x) = Θ(g(x))
(theta) means that the growth rate off(x)
is asymptotically equal to the growth rate ofg(x)
For a more detailed discussion, you can read the definition on Wikipedia or consult a classic textbook like Introduction to Algorithms by Cormen et al.

1If "If an algorithm is of O(g(n)), it means that the running time of the algorithm as n gets larger is at most proportional to g(n)." Then how do you say that "Basically when we say an algorithm is of O(n), it's also O(n2), O(n1000000), O(2n)," ??– Andy897Jan 19 '15 at 13:23

@Andy897 It follows from the definition of "proportional". From Wikipedia: "In mathematics, two variables are proportional if a change in one is always accompanied by a change in the other, and if the changes are always related by use of a constant multiplier. The constant is called the coefficient of proportionality or proportionality constant."– mmxJan 19 '15 at 22:57

What does
>= \Omega(...)
mean? I understand if we say it's a member of\Omega(...)
, but if it's greater than it? What sense does it make? Jun 30 '16 at 11:43 
It's not clear whether "Normally, even when people talk about O(g(n)) they actually mean Θ(g(n))" For example, Quicksort is O(n^2) and Θ(n), and thus doesn't have a tight bound. See the discussion at softwareengineering.stackexchange.com/questions/99372/…– xjiAug 10 '20 at 20:23
There's a simple way (a trick, I guess) to remember which notation means what.
All of the BigO notations can be considered to have a bar.
When looking at a Ω, the bar is at the bottom, so it is an (asymptotic) lower bound.
When looking at a Θ, the bar is obviously in the middle. So it is an (asymptotic) tight bound.
When handwriting O, you usually finish at the top, and draw a squiggle. Therefore O(n) is the upper bound of the function. To be fair, this one doesn't work with most fonts, but it is the original justification of the names.

6I usually never go below 34 answers on any questions. This was worth the ride. Thanks for sharing the trick. :D Aug 31 '18 at 5:46

1I like this. But can you share a source for "it is the original justification of the names"? Feb 10 at 19:59
one is Big "O"
one is Big Theta
http://en.wikipedia.org/wiki/Big_O_notation
Big O means your algorithm will execute in no more steps than in given expression(n^2)
Big Omega means your algorithm will execute in no fewer steps than in the given expression(n^2)
When both condition are true for the same expression, you can use the big theta notation....

21But is wrong! The number of steps is bounded above by n^2 as n gets very large. However, an algorithm that runs in n^2 + c steps takes more than n^2 steps, but is still O(n^2). BigO notation only describes asymptotic beahviour.– HenryRJan 23 '09 at 10:09

1This is not a end all be all definition. It's just a launching point.... Since we are talking about asymptotic notations as n approaches infinity. The constant C becomes a non factor. Jan 23 '09 at 17:13

1While I like the simplicity of this answer, it should be noted that an O(n^2) algorithm could very well take 1,000,000,000*n^2 steps to execute, which is certainly much larger than n^2. An algorithm being O(n^2) just means that it will take no more than k*n^2 steps to execute, where k is some positive real number. Dec 8 '17 at 23:41
Rather than provide a theoretical definition, which are beautifully summarized here already, I'll give a simple example:
Assume the run time of f(i)
is O(1)
. Below is a code fragment whose asymptotic runtime is Θ(n)
. It always calls the function f(...)
n
times. Both the lower and the upper bound is n.
for(int i=0; i<n; i++){
f(i);
}
The second code fragment below has the asymptotic runtime of O(n)
. It calls the function f(...)
at most n
times. The upper bound is n, but the lower bound could be Ω(1)
or Ω(log(n))
, depending on what happens inside f2(i)
.
for(int i=0; i<n; i++){
if( f2(i) ) break;
f(i);
}


1Asymptotic in this context means "for large enough n". The runtime of code fragment whose asymptotic runtime is
Θ(n)
will grow linearly as n increases, e.g. runtime T can be expressed as T(n) = a*n+b. For small values of n (e.g. n=1 or 2) this may not be the best way of describing the behaviour  perhaps you have some initialization code that takes a lot longer than f(i). Oct 6 '14 at 18:22
Theta is a shorthand way of referring to a special situtation where the big O and Omega are the same.
Thus, if one claims The Theta is expression q
, then they are also necessarily claiming that Big O is expression q
and Omega is expression q
.
Rough analogy:
If: Theta claims, "That animal has 5 legs." then it follows that: Big O is true ("That animal has less than or equal to 5 legs.") and Omega is true("That animal has more than or equal to 5 legs.")
It's only a rough analogy because the expressions aren't necessarily specific numbers, but instead functions of varying orders of magnitude such as log(n), n, n^2, (etc.).
A chart could make the previous answers easier to understand:
ΘNotation  Same order  ONotation  Upper bound
In English,
On the left, note that there is an upper bound and a lower bound that are both of the same order of magnitude (i.e. g(n) ). Ignore the constants, and if the upper bound and lower bound have the same order of magnitude, one can validly say f(n) = Θ(g(n)) or f(n) is in big theta of g(n).
Starting with the right, the simpler example, it is saying the upper bound g(n) is simply the order of magnitude and ignores the constant c (just as all big O notation does).


@kushalvm, thanks for your honesty. Could you kindly explain what do you mean specifically? For the sake of my learning and others that may get confused with this answer. :)– RicardoJul 20 '18 at 23:01


@kushalvm, thanks for clarifying it. I changed the text of the last line of the paragraph before the last to fix my English mistake.– RicardoJul 23 '18 at 23:51

f(n)
belongs to O(n)
if exists positive k
as f(n)<=k*n
f(n)
belongs to Θ(n)
if exists positive k1
, k2
as k1*n<=f(n)<=k2*n

1You missed a crucial point  these are true only for all n > n1, i.e. asymptotically.– HenryRJan 23 '09 at 10:11

Using limits
Let's consider f(n) > 0
and g(n) > 0
for all n
. It's ok to consider this, because the fastest real algorithm has at least one operation and completes its execution after the start. This will simplify the calculus, because we can use the value (f(n)
) instead of the absolute value (f(n)
).
f(n) = O(g(n))
General:
f(n) 0 ≤ lim ──────── < ∞ n➜∞ g(n)
For
g(n) = n
:f(n) 0 ≤ lim ──────── < ∞ n➜∞ n
Examples:
Expression Value of the limit  n = O(n) 1 1/2*n = O(n) 1/2 2*n = O(n) 2 n+log(n) = O(n) 1 n = O(n*log(n)) 0 n = O(n²) 0 n = O(nⁿ) 0
Counterexamples:
Expression Value of the limit  n ≠ O(log(n)) ∞ 1/2*n ≠ O(sqrt(n)) ∞ 2*n ≠ O(1) ∞ n+log(n) ≠ O(log(n)) ∞
f(n) = Θ(g(n))
General:
f(n) 0 < lim ──────── < ∞ n➜∞ g(n)
For
g(n) = n
:f(n) 0 < lim ──────── < ∞ n➜∞ n
Examples:
Expression Value of the limit  n = Θ(n) 1 1/2*n = Θ(n) 1/2 2*n = Θ(n) 2 n+log(n) = Θ(n) 1
Counterexamples:
Expression Value of the limit  n ≠ Θ(log(n)) ∞ 1/2*n ≠ Θ(sqrt(n)) ∞ 2*n ≠ Θ(1) ∞ n+log(n) ≠ Θ(log(n)) ∞ n ≠ Θ(n*log(n)) 0 n ≠ Θ(n²) 0 n ≠ Θ(nⁿ) 0
Conclusion: we regard big O, big θ and big Ω as the same thing.
Why? I will tell the reason below:
Firstly, I will clarify one wrong statement, some people think that we just care the worst time complexity, so we always use big O instead of big θ. I will say this man is bullshitting. Upper and lower bound are used to describe one function, not used to describe the time complexity. The worst time function has its upper and lower bound; the best time function has its upper and lower bound too.
In order to explain clearly the relation between big O and big θ, I will explain the relation between big O and small o first. From the definition, we can easily know that small o is a subset of big O. For example：
T(n)= n^2 + n, we can say T(n)=O(n^2), T(n)=O(n^3), T(n)=O(n^4). But for small o, T(n)=o(n^2) does not meet the definition of small o. So just T(n)=o(n^3), T(n)=o(n^4) are correct for small o. The redundant T(n)=O(n^2) is what? It's big θ!
Generally, we say big O is O(n^2), hardly to say T(n)=O(n^3), T(n)=O(n^4). Why? Because we regard big O as big θ subconsciously.
Similarly, we also regard big Ω as big θ subconsciously.
In one word, big O, big θ and big Ω are not the same thing from the definitions, but they are the same thing in our mouth and brain.

Why is this content formatted as a quote? Is it a quote from an external source? If so, the source should be linked or otherwise identified. If not, the quote formatting should be removed. Sep 1 '19 at 16:42