Is the time complexity when it comes to maps AND sets the same for operations like insertion, removal, search ? I read somewhere that underlying structure is a hash table meaning that time would be constant o(1) ? is that always the case ?
Asked
Active
Viewed 900 times
1 Answers
0
Map
and Set
are just interfaces and say nothign about time complexity. Java SE provides different implementations (e.g. HashMap
, TreeMap
, HashSet
, TreeSet
, ...) that are based on different concepts and hence have different strengths and weaknesses concerning time complexity. Have a look at JavaDoc of every implementation, there the time complexity is explained for all important operations/methods!

isnot2bad
- 24,105
- 2
- 29
- 50
-
One thing to note is that a `HashSet` _is a_ `HashMap` and a `TreeSet` _is a_ `TreeMap`. – Boris the Spider Sep 28 '13 at 10:33