C Program To Implement Dictionary Using Hashing Algorithms [better] Link
Replace % size with & (size - 1) when size is a power of two.
The heart of a dictionary is the hash function. It takes a "key" (usually a string) and converts it into an integer index. A good hash function distributes keys uniformly across the table to minimize collisions. Collision Handling c program to implement dictionary using hashing algorithms
unsigned long hash(char *str) unsigned long hash = 5381; int c; while ((c = *str++)) hash = ((hash << 5) + hash) + c; return hash % TABLE_SIZE; Replace % size with & (size - 1) when size is a power of two
A dictionary entry needs a , a value , and a pointer to the next entry in case of a hash collision. 5) + hash) + c
Let's analyze the time complexities:
return hash_value % table_size;