Big O Notation of an expression

后端 未结 6 1649
南笙
南笙 2021-02-06 10:22

If I have an algorithm that takes 4n^2 + 7n moves to accomplish, what is its O? O(4n^2)? O(n^2)?

I know that 7n is cut off, but I don\'t know if I should keep the n^2 c

6条回答
  •  感情败类
    2021-02-06 11:04

    The coefficients aren't relevant in Big O notation, so it's just O(n2). As Wikipedia explains:

    [...] the coefficients become irrelevant if we compare to any other order of expression, such as an expression containing a term n3 or n2.

提交回复
热议问题