Question: - Execute the calc _ hash function shown in the hash search example below with multiple inputs on a PC and display the results (

- Execute the calc_hash function shown in the "hash search example" below with multiple inputs on a PC and display the results (hash values).
- It can also be executed by simply adding the main function:
int main()
{
printf(%dn, calc_hash(computer));
printf(%dn, calc_hash(California));
...
return 0;
}
- TAB_SIZE must be defined appropriately.
"hash search example"
Table* tab[TAB_SIZE];
int calc_hash(char* name)
{
int i, hash_val;
hash_val=0;
while (*name !=0)
hash_val +=*name++;
return hash_val%TAB_SIZE;
}
Table* lookup_tab(char* name)
{
Table* pe;
for (pe=tab[calc_hash(name)]; pe!=NULL; pe=pe->next){
if (strcmp(pe->name, name)==0)
return pe;
}
return NULL;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!