Hi, I would like to construct a hash table that looks up keys in sequences (strings) of bytes ranging from 1 to 15 bytes.
I would like to store an integer value, so I imagine an array for hashing would suffice. I'm having difficulty conceptualizing how to construct a hash function such that given the key would give an index into the array.
Any assistance would be much appreiated.
The maximum number of entries in the hash is: 4081*15 + 4081*14 + ... 4081 = 4081((15*(16))/2) = 489720.
So for example:
int table[489720];
int lookup(unsigned char *key)
{
int index = hash(key);
return table[index];
}
What are some good choices for a hash function, or how would I go about constructing one?
Thanks.