PROGRAM of how hashtable collision can occur?
I have read that a hash collision only means that the hashCode is not unique, which puts you into calling equals(), and the more duplicates there are the worse the performance.
PROGRAM of how hashtable collision can occur?
I have read that a hash collision only means that the hashCode is not unique, which puts you into calling equals(), and the more duplicates there are the worse the performance.
This is at least partly answered here: How do HashTables deal with collisions?
Collisions occur when two different values are hashed into the same slot. For example, if 2,450 keys are hashed into a million buckets, even with a perfectly uniform random distribution, according to the birthday problem there is approximately a 95% chance of at least two of the keys being hashed to the same slot (Source: Wikipedia; https://en.wikipedia.org/wiki/Hash_table).