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

后端 未结 16 2264
栀梦
栀梦 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:37

    Basically, O(1) means its computation time is constant, while O(n) means it will depend lineally on the size of input - i.e. looping through an array has O(n) - just looping -, because it depends on the number of items, while calculating the maximum between to ordinary numbers has O(1).

    Wikipedia might help as well: http://en.wikipedia.org/wiki/Computational_complexity_theory

提交回复
热议问题