Design a C Function that creates and fills a hash table. Hash(int* table, int* input, int M, int X); The function should look like this where table = an array used to store the hashed values input =...

1 answer below »

Design a C Function that creates and fills a hash table.


Hash(int* table, int* input, int M, int X);


The function should look like this where



  • table = an array used to store the hashed values

  • input = an array of integers

  • M = length of both the input array and hash table.

  • X = value used for the double hash

  • Double hashes will handle the collisions.

  • The function needs to implement these hashes:

  • h(k) = (h1(k) + h2(k)*i) mod M, where i=1:M, or i=0:M

  • h1(k) = k mod M

  • h2(k) = X - (k mod X)

Answered Same DayApr 19, 2021

Answer To: Design a C Function that creates and fills a hash table. Hash(int* table, int* input, int M, int X);...

Vaishnavi R answered on Apr 19 2021
144 Votes
#include
int h1(int key,int m)
{
return (key % m);
}
int h2(int key,int m,int x)

{
return (x - (key % x));
}
void Hash(int* table, int* input, int M, int X)
{
for(int i=0; i {
int key = input[i];
int index = h1(key,M);
if (table[index] != -1)
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here