Can the complexity of an algorithm be at the time in O(n^2) and in O(n logn)? i am sure about this one. But what about in Ω(n^2) and in O(n logn), also and in Θ(n^2) and in Ω(n logn). Thanks
1 Answer
Big-O notation refers only to the upper bound. Thus, if it is in
O(n log n), it is necessarily inO(n^2)(sincen^2grows faster thann log n).No, it cannot be in both
Ω(n^2)and inO(n log n). That would mean "upper bounded byn log nand lower bounded byn^2, which is impossible.Θ(n^2)means it is bounded both above and below byn^2, which necessarily means it is bounded below byΩ(n log n).
1 Comment
sully11
thanks, but what about in Ω(n^2) and in O(n logn) it seems correct.
and in (n logn)- did you mean to put anO, anΩ, or aΘthere before the parentheses?