Big O Notation of an expression

后端 未结 6 1739
南笙
南笙 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 10:48

    Mathematically speaking, you would write O(4n²). It means that the complexity function of your algorithms behaves as n->4n² towards positive infinite.

    But in computer science/algorithm, you would only write O(n²), which is sufficient to categorize your algorithm.

提交回复
热议问题