3

I was reading this question Big-O notation's definition.
But I have less than 50 reputation to comment, so I hope someone help me.

My question is about this sentence:

There are many algorithms for which there is no single function g such that the complexity is both O(g) and Ω(g). For instance, insertion sort has a Big-O lower bound of O(n²) (meaning you can't find anything smaller than n²) and an Ω upper bound of Ω(n).

for large n the O(n²) is an upper bound and Ω(n) is a lower bound, or maybe I have misunderstood? could someone help me?

enter image description here

O-BL
  • 326
  • 3
  • 12

2 Answers2

2

maybe I have misunderstood?

No, you are right.

In general, the Big-O is for the upper bound and big-Ω for the lower bound.

For Insertion sort the worst case scenario, the upper bound is O(n2). Ω(n) is a lower bound.

It seems like you find a mistake in the other answer.

gsamaras
  • 71,951
  • 46
  • 188
  • 305
2

has a Big-O lower bound of O(n²)

I don't really agree with the confusing way this was phrased (since big-O is itself an upper bound), but what I'm reading here is the following:

Big-O is an upper bound.

That is to say, f(n) ϵ O(g(n)) is true if |f(n)| <= k|g(n)| as n tends to infinity (by definition).

So let's say we have a function f(n) = n2 (which is, if we ignore constant factors, the worst-case for insertion sort). We can say n2 ϵ O(n2), but we can also say n2 ϵ O(n3) or n2 ϵ O(n4) or n2 ϵ O(n5) or ....

So the smallest g(n) we can find is n2.


But the answer you linked to is, as a whole, incorrect - insertion sort itself does not have upper or lower bounds, but rather it has best, average and worst cases, which have upper and lower bounds.

See the answer I posted there.

Bernhard Barker
  • 54,589
  • 14
  • 104
  • 138
  • could you tell me, what is the omega notation for Fibonacci algorithm; and how to calculate it? – O-BL Sep 09 '17 at 14:08
  • 1
    @O-BL See [Exponential lower bound for Fibonacci numbers](https://math.stackexchange.com/questions/571433/exponential-lower-bound-for-fibonacci-numbers) – Bernhard Barker Sep 09 '17 at 14:13