Hash Table: Should I increase the element count on collisions?

Posted by Nazgulled on Stack Overflow See other posts from Stack Overflow or by Nazgulled
Published on 2010-04-18T14:31:48Z Indexed on 2010/04/18 14:33 UTC
Read the original article Hit count: 275

Hi,

Right now my hash tables count the number of every element inserted into the hash table. I use this count, with the total hash table size, to calculate the load factor and when it reaches like 70%, I rehash it.

I was thinking that maybe I should only count the inserted elements with fills an empty slot instead of all of them. Cause the collision method I'm using is separate chaining. The factor load keeps increasing but if there can be a few collisions leaving lots of empty slots on the hash table.

You are probably thinking that if I have that many collisions, maybe I'm not using the best hashing method. But that's not the point, I'm using one of the know hashing algorithms out there, I tested 3 of them on my sample data and selected the one who produced less collisions.

My question still remains. Should I keep counting every element inserted, or just the ones that fill an empty slot in the Hash Table?

© Stack Overflow or respective owner

Related posts about hashtable

Related posts about hash-collision