开发者

What does O(1) and O(N) mean in MSDN documentation?

开发者 https://www.devze.com 2023-02-05 08:22 出处:网络
If you scroll 2/3 of t开发者_StackOverflow社区he way down this article, it refers to O(1).Can someone explain what this means? This is called "Big O" notation.It tells you how efficient an a

If you scroll 2/3 of t开发者_StackOverflow社区he way down this article, it refers to O(1). Can someone explain what this means?


This is called "Big O" notation. It tells you how efficient an algorithm is based on the number of elements it has to process.

  • O(1) = The process takes a constant amount of time no matter how many elements there are.
  • O(n) = The processing time has linear growth based on the number of elements.

Wikipedia has a table that shows the common "Big O" functions: http://en.wikipedia.org/wiki/Big_O_notation#Orders_of_common_functions


In simple terms, this means that as the length of the list tends toward infinity, the O(1) operation does not significantly change in duration.

Compare this to an O(n) operation, where if you double the length of the list, you double the length of the operation.


Big O notation

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号