According to this, time complexity of search in a hashtable is O(1).
However if there is a collision, then obviously this should be O(1) + something.
My question is:
When you say
get(someKey)
from a hashtable, the hashing function is applied to the someKey, and the data is directly retrieved from that location.
But imagine Seperate Chaining is used for collision resolution. And imagine someKey and someOtherKey have same output after our hashing function is applied on them. Say that it is the value "25".
So when I say
get(someKey)
I will get the data from location "25". Which makes it O(1). Great.
However when I say
get(someOtherKey)
Now someOtherKey is linked to where someKey is.
When the hashing is applied on someOtherKey I get 25.
How do I get the value I reqiure? What are the internals? Is there some other table? How does the algorithm flow? Is there some other table for storing all the collisions?
Thank you. I hope my question is clear!