Time Complexity of HashMap methods

前端 未结 5 1019
走了就别回头了
走了就别回头了 2020-12-13 19:21

Since i\'m working around time complexity, i\'ve been searching through the oracle Java class library for the time complexity of some standard methods used on Lists, Maps an

5条回答
  •  天涯浪人
    2020-12-13 19:55

    The source is often helpful: http://kickjava.com/src/java/util/HashMap.java.htm

    • remove: O(1)
    • size: O(1)
    • values: O(n) (on traversal through iterator)

提交回复
热议问题