I'll be needing to use Hash Tables with different keys. One as string for the key and another as integer.
As for the integer one, how stupid it is to run a hash function on the number to generate a key?
I mean, the numbers I'll be using as key for the Hash Table will always be different, there will be no duplicates at all. Isn't enough for me to use the mod operator to "truncate" the value below the hash table size?
Or there's something more to it?
It is fine unless there's a high chance that your integer keys are 62, 93, 124, ... and your hash table size happens to be 31.
See What integer hash function are good that accepts an integer hash key? if you worry about this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With