data structure with O(1) search time complexity in c++

  • A+
Category:Languages

is there a data structure in c++ that has a search time complexity of O(1)? As in to check if an element is present in it or not, and if present, what its position or associated index/ key/value is

 


What you want is C++11's std::unordered_map, with an average access time of O(1) and a worst case of O(n).

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: