My question has to do with collisions. What is the maximum number of collisions that may result from hashing n keys? I believe you would be able to find this by taking n-1. But I am unsure if this is correct. I'm specifically trying to figure out a hash function that would produce that many collisions. I'm just having a hard time understand the concept of the question. Any help on the subject would be appreciated!
Asked
Active
Viewed 6,209 times
0
-
You can get as many collisions as possible with `hash(x)=1` – John Dvorak Sep 07 '16 at 17:02
-
What is it you are really trying to figure out? As you can see by the two answers (so far), the question asked may not be what you intended. – wallyk Sep 07 '16 at 17:03
-
I'm just trying to understand what hash function would give me the maximum number of collisions when you hash "n" keys. I know its a vague question. I don't really understand the question myself. – mm19 Sep 07 '16 at 17:11
2 Answers
3
The maximum number of collisions is equal to the number of items you hash.
Example:
hash function: h(x) = 3
All items will be hashed to key 3.
Notice that number of keys, n
in your case, doesn't affect the answer, since no matter how many keys you have, your items are always going to be hashed in key 3, with the h(x)
I provided above.
Visualization:
Usually, hashing looks like this:
but if I want to have the maximum number of collisions, then, by using the h(x)
provided above I will get all my items (the names in the picture) all hashed to the vary same key, i.e. key 3.
So in that case the maximum number of collisions is the number of names, 5.

gsamaras
- 71,951
- 46
- 188
- 305
0
Maximum expected number of collision in uniform hashing is $$O(\frac{log(n)}{loglog(n)})$$

Subhankar Ghosal
- 159
- 1
- 7