I need some help passing a array of integers into a hash table by chaining. So if the array is filled it that location it will go to a linked list of the index. any ideas on how to get this done. This is what i have so far.

chainFunc(int size,  int *keysB)  //size of the array and a array of keys.

int Hashtable[size];

for (i=0, i < size, i++)   //increment thru the array of keysB
{
index = *keysB % size   //index of keys

HashTable[index] = *keysB   //assign keys array to another array with correct index.

}

I need some help passing a array of integers into a hash table by chaining. So if the array is filled it that location it will go to a linked list of the index. any ideas on how to get this done. This is what i have so far.

chainFunc(int size,  int *keysB)  //size of the array and a array of keys.

int Hashtable[size];

for (i=0, i < size, i++)   //increment thru the array of keysB
{
index = *keysB % size   //index of keys

HashTable[index] = *keysB   //assign keys array to another array with correct index.

}

With posted code this short, it should be code that compiles, not pseudocode that doesn't. What is chainFunc's return type? Where are the starting and ending brackets? i is not declared. If you are working on hash tables, you know the basics of how to create a function and how to declare variables, so the posted code should be at least correct in terms of that.

How many buckets does your hash table have? Is each bucket supposed to be a linked list? It isn't the way you have it. Look at lines 7 and 9. Do these lines make any sense to you as far as accessing an array? Your loop variable i isn't even used.

Think about these issues and give it another shot.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.