In popular literature, complexities are usually used in a very imprecise manner, often to describe the runtime performance of an algorithm and denoted with "$O$". My question is about these Landau symbols.

Take Quicksort for example, which is often cited as being $O(n^2)$ in the worst case, but $O(n \log(n))$ in the best one. To my understanding though, it is also $O(n^2)$ in the best case, since $n\log(n)$ is asymptotically bounded from above by $n^2$.

My question now is: is there a notion of a "least upper bound" complexity when using Landau symbols? When I call an algorithm $O(n^2)$, does this mean that $n^2$ is the slowest growing function that still bounds the runtime from above, or is this just a moral imperative?

(Similar issues of course apply to other Landau symbols, such as lower bounds.)

  • $\begingroup$ "Take Quicksort for example, which is often cited as being O(n^2) in the worst case, but O(n*log(n)) in the best one." - Actually, a best case of $O(n)$ can be achieved, with certain implementations. It is $O(n \log n)$ on average. $\endgroup$ Oct 4, 2014 at 12:41
  • $\begingroup$ Yes. I think you are looking for $\Omega$ (and $\Theta$); Wikipedia lists them and we have a reference question. Do these sources answer your query? $\endgroup$
    – Raphael
    Oct 4, 2014 at 13:01
  • $\begingroup$ On second thought, there are cases in which $f \in O(g)$ and $f \not\in o(g)$ but also $f \not\in \Omega(g)$. Is this the scenario you are asking about? (Since here, you can't use $\Theta$ but only $O$ which does not say "this is the best possible bound".) $\endgroup$
    – Raphael
    Oct 4, 2014 at 13:03


Browse other questions tagged or ask your own question.