Big O vs Small omega

☆樱花仙子☆ 提交于 2019-12-11 02:04:13

问题


Why is ω(n) smaller than O(n)?

I know what is little omega (for example, n = ω(log n)), but I can't understand why ω(n) is smaller than O(n).


回答1:


Algorithmic complexity has a mathematic definition.

If f and g are two functions, f = O(g) if you can find two constants c (> 0) and n such as f(x) < c * g(x) for every x > n.

For Ω, it is the opposite: you can find constants such as f(x) > c * g(x).

f = Θ(g) if there are three constants c, d and n such as c * g(x) < f(x) < d * g(x) for every x > n.

Then, O means your function is dominated, Θ your function is equivalent to the other function, Ω your function has a lower limit. So, when you are using Θ, your approximation is better for you are "wrapping" your function between two edges ; whereas O only set a maximum. Ditto for Ω (minimum).

To sum up:

  • O(n): in worst situations, your algorithm has a complexity of n
  • Ω(n): in best case, your algorithm has a complexity of n
  • Θ(n): in every situation, your algorithm has a complexity of n

To conclude, your assumption is wrong: it is Θ, not Ω. As you may know, n > log(n) when n has a huge value. Then, it is logic to say n = Θ(log(n)), according to previous definitions.




回答2:


Big Oh 'O' is an upper bound and little omega 'ω' is a Tight lower bound.

O(g(n)) = { f(n): there exist positive constants c and n0 such that 0 ≤ f(n) ≤ cg(n) for all n ≥ n0}

ω(g(n)) = { f(n): for all constants c > 0, there exists a constant n0 such that 0 ≤ cg(n) < f(n) for all n ≥ n0}. ALSO: infinity = lim f(n)/g(n)

n ∈ O(n) and n ∉ ω(n). Alternatively: n ∈ ω(log(n)) and n ∉ O(log(n))




回答3:


I can't comment, so first of all let me say that n ≠ Θ(log(n)). Big Theta means that for some positive constants c1, c2, and k, for all values of n greater than k, c1*log(n) ≤ n ≤ c2*log(n), which is not true. As n approaches infinity, it will always be larger than log(n), no matter log(n)'s coefficient.

jesse34212 was correct in saying that n = ω(log(n)). n = ω(log(n)) means that n ≠ Θ(log(n)) AND n = Ω(log(n)). In other words, little or small omega is a loose lower bound, whereas big omega can be loose or tight.

Big O notation signifies a loose or tight upper bound. For instance, 12n = O(n) (tight upper bound, because it's as precise as you can get), and 12n = O(n^2) (loose upper bound, because you could be more precise).

12n ≠ ω(n) because n is a tight bound on 12n, and ω only applies to loose bounds. That's why 12n = ω(log(n)), or even 12n = ω(1). I keep using 12n, but that value of the constant does not affect the equality.

Technically, O(n) is a set of all functions that grow asymptotically equal to or slower than n, and the belongs character is most appropriate, but most people use "= O(n)" (instead of "∈ O(n)") as an informal way of writing it.




回答4:


ω(n) and O(n) are at the opposite side of the spectrum, as is illustrated below.

Formally,

For more details, see CSc 345 — Analysis of Discrete Structures (McCann), which is the source of the graph above. It also contains a compact representation of the definitions, which makes them easy to remember:



来源:https://stackoverflow.com/questions/27873104/big-o-vs-small-omega

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!