What does “O(1) access time” mean?

后端 未结 16 2266
栀梦
栀梦 2020-11-28 18:21

I have seen this term \"O(1) access time\" used to mean \"quickly\" but I don\'t understand what it means. The other term that I see with it in the same context is \"O(n) ac

16条回答
  •  生来不讨喜
    2020-11-28 18:51

    You're going to want to read up on Order of complexity.

    http://en.wikipedia.org/wiki/Big_O_notation

    In short, O(1) means that it takes a constant time, like 14 nanoseconds, or three minutes no matter the amount of data in the set.

    O(n) means it takes an amount of time linear with the size of the set, so a set twice the size will take twice the time. You probably don't want to put a million objects into one of these.

提交回复
热议问题