0

I am trying to optimize my hash function, for a separate chaining hash table that I have created from scratch. My hash function is as follows:

```
int hash( const string &key, int tableSize)
{
int hashVal = 0;
for(int i = 0; i<key.length(); i++)
hashVal = 37*hashVal+key[i];
hashVal %= tableSize;
if(hashVal<0)
hashVal += tableSize;
return hashVal;
}
```

I was wondering if one could point me to either a better hash function or how I should go about modifying this function.