Ad
  • Custom User Avatar

    I understand now. Thank you for the explanation and for recommending a resource.

  • 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.

  • Custom User Avatar

    Disclaimer: I am very new at programming. I'm trying to learn by asking questions. If I offend by my question, please forgive me. I only know enough to be dangerous.

    If you make the hash table twice as large as a3 with the goal of reducing collisions, why wouldn't you just make the hash table of size 'a1 * a2'? Wouldn't that eliminate all possibility of collisions?