Time complexity - least upper bound

I know that Big $O$ notation is used to describe the upper bound of running time of an algorithm, if we consider time complexity of that algorithm. However, I'm not sure why the following is not stated everytime anyone attempts to explain time complexity or Big $O$ - the fact we're looking for the least upper bound of the running time.

Correct me if I'm wrong, but $O(n!)$ is known to be the highest complexity - much worse than exponential. If I have an algorithm whose running time is $O(n)$, then it is also $O(n^2)$, $O(n^3)$, $O(2^n)$, and $O(n!)$, because they are all upper bounds of its running time (I know that, because it's $O(n)$).

So is it possible to find the least upper bound of the running time? If I read an algorithm has complexity $O(2^n)$, does it mean it has been proven this is the least upper bound? Or is it just the smallest upper bound that has been found so far?

• In your second paragraph, $O(n!)$ is by far not the highest complexity. Take, for example, the function $n!^{n!}$. For the body of your question, have you looked at $\Theta(.)$ estimates (aka, big-Theta)? They apply here. – Rick Decker Dec 2 '15 at 22:21
• cs.stackexchange.com/q/23068/755 – D.W. Dec 3 '15 at 7:07
• @D.W. check page 23 here to see what I mean (the last sentence on that page). Running time of an algorithm can be $O(n^2)$, but how do we know if it's not $O(n)$? If somebody tells me this algorithm is $O(n^2)$, does it mean he has proven there doesn't exist a smaller upper bound, for instance $O(n)$? – user4205580 Dec 3 '15 at 9:12

If you want to state that $O(f(n))$ is the best bound on the complexity that you can get, then you can use big Theta instead: $\Theta(f(n))$ stands for a function – in this case worst-case time complexity – that is asymptotically equal to $f(n)$ up to constants. That is, if the worst-case time complexity $T(n)$ satisfies $cf(n) \leq T(n) \leq Cf(n)$ for some $0<c\leq C$, then you can state that the (worst-case) time complexity of the algorithm is $\Theta(f(n))$. This implies both the upper bound $O(f(n))$ and the matching lower bound $\Omega(f(n))$, showing that the upper bound is best possible.
• If bubble sort has complexity $O(n)$, does it mean it has been proven this is the least upper bound possible (meaning no smaller upper bound exists)? Or is it the least upper bound that has been found so far? – user4205580 Dec 3 '15 at 19:55