Let us suppose the best case running time of an algorithm is $\Theta(n \log n)$. Can the average case run time of the algorithm be $O(n \log n)$? Since $O(n\log n)$ would imply the value going even below $n \log n$ hence would be lower than the best case bound of $\Theta(n \log n)$. Is this possible?
Asked
Active
Viewed 28 times
0
-
1"$O(n \log n)$ would imply the value going even below $n \log n$" -- This is false unless you mean $o(n \log n)$ (notice the non-capital "$o$"). In particular, $\Theta(n \log n) \subseteq O(n \log n)$, so what you are asking is possible if, for example, the average and best cases have the same complexity. – dkaeae Feb 25 '19 at 16:37
-
"$O(nlogn)$ would imply the value going even below $nlogn$" Why is is false? Doesnt $O$ mean an upper bound? @dkaeae – ephemeral Feb 25 '19 at 16:42
-
1@ephemeral An upper bound is different from a strict upper bound, I suggest you look up the difference in the terms. Also, the fact that we are dealing with upper bounds in asymptotic complexity can further complicate the matter, although it doesn't seem to matter much here. – Discrete lizard Feb 25 '19 at 17:11
-
@Discretelizard Doesnt the definition of $O$ say that $f(n) \leq cg(n)$? So, doesn't that mean the value could be anything below $n log n$? Or am I missing something here? – ephemeral Feb 25 '19 at 17:22
-
Yes I understand the value can be equal to $nlogn$ as well, what I am confused about is why can it be $O(n log n)$. That would imply all values from 0...$nlogn$? If so, we already know the best case to be $\Theta(nlogn)$ hence it can't go below that value. That's what I am confused why can it be $O(nlog n)$ and not $\Omega(nlogn)$ – ephemeral Feb 25 '19 at 17:42
-
1@ephemeral "anything below $n\log n$" That includes $n\log n$ itself. – Discrete lizard Feb 25 '19 at 18:06