unsigned int hash(const char *key, int size) unsigned int hash_val = 5381; int c; while ((c = *key++)) hash_val = ((hash_val << 5) + hash_val) + c; // djb2: hash * 33 + c return hash_val % size; Use code with caution. Copied to clipboard Essential Operations
while (current != NULL) if (current->key == key) return current->value; c program to implement dictionary using hashing algorithms
display(&ht);
Next, define the hash table structure:
delete_key(dict, "grape");