-3

I want to create a hash table in c++ for storing strings. I am willing to write a good hash function to avoid collisions as much as possible. As a sample hash function I have used the following method:

function Hash(string)

return (summation of the ASCII values of the characters in the string) mod PrimeNumber

end

Is this function good enough to avoid collisions or is there any other good function ? please help :)

N.B: No STL is allowed

1 Answers1

2

c++11 already comes with a good hash function for string you don't need to introduce one. See: http://www.cplusplus.com/reference/unordered_map/unordered_map/operator[]/

W.F.
  • 13,888
  • 2
  • 34
  • 81