Ad
  • Custom User Avatar

    Ok. Quantity of collisions depends on tash table size and hash function. Let's see an example, where we have hash table with size 25, len(a1) = 5, len(a2) = 5 and a3 = [125, 300, 50]. According to my hash function: 125 mod 25 = 0, 300 mod 25 = 0, 50 mod 25 = 0. So we have hash table [ [125, 300, 50], [], [], [], .... ] (I use hash table with chains). We have 2 collisions in hash table with size 25. Not so good. And whats wrong? Conclusion: we need to build hash table according length of our array, which will be stored in hash table. By the way, hash function also have a big influence on quantity of collisions. If you interested in this question, you can read Introduction to Algorithms by Cormen.