The average case time complexity for search in an unordered set in C++ O(1) but for worst case it is O(n). The same goes for insertion and deletion.
How does that work? The worst case time complexity for search should be when the element is not present in the map. If that takes O(n) time, it means that it tranverses the whole unordered set once. But if that's the case, shouldn't the average case complexity be O(n) as follows:
(1 + 2 + ... + n) / n = (n + 1) / 2
This means that there must be some other algorithm implemented to search. What's the algorithm?