I'm trying to deal with asymptotic complexity of HashMap
, LinkedHashMap
and TreeMap
. On different sites and articles write that on average get
= O(1)
and at worst - O(n)
. (if all keys add to one bucket).
But I read book Bruce Eckel thinking in java
and there is an example of comparison
If you look at this data, then it goes out O(n)
I am completely confused. Can anyone explain the asymtotic complexity of Map
realizations - HashMap
, LinkedHashMap
and TreeMap
, at least for get
and put
? (maybe there is a good article where everything is clear and put together?)
EDIT
Most interested in the put
method. Since when a certain size occurs resize()
similarly as in ArrayList
.