0

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 ?

Dodi
  • 2,201
  • 4
  • 30
  • 39

1 Answers1

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