Issue
I need to know: What is the time complexity of HashMap.containsKey() in java?
Solution
From the API doc of
HashMap:
This implementation provides constant-time performance for the basic operations (get and put), assuming the hash function disperses the elements properly among the buckets.
Since containsKey()
is just a get()
that throws away the retrieved value, it's O(1) (assuming the hash function works properly, again).
Answered By - Michael Borgwardt Answer Checked By - David Goodson (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.