Can you do addition/multiplication with Big O notations?

前端 未结 4 740
执念已碎
执念已碎 2021-01-03 04:10

I\'m currently taking an algorithm class, and we\'re covering Big O notations and such. Last time, we talked about how

O (n^2 + 3n + 5) = O(n^2)
4条回答
  •  臣服心动
    2021-01-03 04:57

    In complexity theory, the Landau symbols are used for sets of functions. Therefore O(*) does not represent a single function but an entire set. The + operator is not defined for sets, however, the following is commonly used when analyzing functions:

    O(*) + g(n)
    

    This usually represents a set of functions where g(n) is added to every function in O(*). The resulting set can be represented in big-O notation again.

    O(*) + O(**)
    

    This is similar. However, it behaves like a kind of cartesian product. Every function from O(**) is added to every function from O(*).

    O(*) + Θ(*)
    

    The same rules apply here. However, the result can usually not be expressed as Θ(**) because of the loosening by O(*). Expressing it as O(**) is still possible.

提交回复
热议问题