From what I have read online, there are two ways of decreasing the number of collisions:
- Use a better hash function
- Increase the size of your hashtable
I can understand the first reason but I cannot seem to get my head around the second.
If lets say I have 5 keys all whose hashes are the same. Lets say we are using chaining for collision resolution. All 5 keys will form a chain starting from the index that equals the hash value. Now, lets say I double the size of the table and rehash all the 5 keys. The 5 keys will still hash to the same index and will still form a change of size 5. How did increasing the size of hash table decrease collisions?