I have found many posts about the complexity of map
and unordered_map
. It is said that unordered_map
has worst case complexity of O(N)
. For my purpose I will have input as sorted values like 1 2 5 6 9 11 12..
. I need to insert or find and delete a value. I will have to do insert/delete quite frequently. I thought of using set
which has log(n) complexity in all cases. And then I stumbled upon unordered_map which has best O(1) complexity. But I need to understand in my scenario will I face the worst case scenario of unordered_map? And what will be the scenario?
EDIT: In my case all the values will be unique.