What is the difference between Θ(n) and O(n)?

后端 未结 9 1025

Sometimes I see Θ(n) with the strange Θ symbol with something in the middle of it, and sometimes just O(n). Is it just laziness of typing because nobody knows how to type th

9条回答
  •  南笙
    南笙 (楼主)
    2020-11-22 05:07

    A chart could make the previous answers easier to understand:

    Θ-Notation - Same order | O-Notation - Upper bound

    Θ(n) - Same order O(n) - Upper bound

    In English,

    On the left, note that there is an upper bound and a lower bound that are both of the same order of magnitude (i.e. g(n) ). Ignore the constants, and if the upper bound and lower bound have the same order of magnitude, one can validly say f(n) = Θ(g(n)) or f(n) is in big theta of g(n).

    Starting with the right, the simpler example, it is saying the upper bound g(n) is simply the order of magnitude and ignores the constant c (just as all big O notation does).

提交回复
热议问题