What exactly does big Ө notation represent?

前端 未结 6 2363
南笙
南笙 2020-11-22 11:31

I\'m really confused about the differences between big O, big Omega, and big Theta notation.

I understand that big O is the upper bound and big Omega is the lower b

6条回答
  •  说谎
    说谎 (楼主)
    2020-11-22 12:18

    Theta(n): A function f(n) belongs to Theta(g(n)), if there exists positive constants c1 and c2 such that f(n) can be sandwiched between c1(g(n)) and c2(g(n)). i.e it gives both upper and as well as lower bound.

    Theta(g(n)) = { f(n) : there exists positive constants c1,c2 and n1 such that 0<=c1(g(n))<=f(n)<=c2(g(n)) for all n>=n1 }

    when we say f(n)=c2(g(n)) or f(n)=c1(g(n)) it represents asymptotically tight bound.

    O(n): It gives only upper bound (may or may not be tight)

    O(g(n)) = { f(n) : there exists positive constants c and n1 such that 0<=f(n)<=cg(n) for all n>=n1}

    ex: The bound 2*(n^2) = O(n^2) is asymptotically tight, whereas the bound 2*n = O(n^2) is not asymptotically tight.

    o(n): It gives only upper bound (never a tight bound)

    the notable difference between O(n) & o(n) is f(n) is less than cg(n) for all n>=n1 but not equal as in O(n).

    ex: 2*n = o(n^2), but 2*(n^2) != o(n^2)

提交回复
热议问题