Dear friends,
hello to you all as this is my first thread - question to the forum.
This is my problem, which is a school exersize:
I create a linked list which contains three numbers r,c,d per node
From this list I have to create a hash table htable[7] with hash function
hk=d mod 7
my idea of doing it is through the following code, where htable and fnl are hash tables and curr is a structure of the same type.
while (curr != NULL)
{
if (htable[hk]==NULL) {
htable[hk]=curr;
fnl[hk]=curr;
}
else {
fnl[hk]->next=curr;
fnl[hk]=curr;
}
curr=curr->next;
doing it what I get as a result is that each of the linked lists of the htable have all the correct nodes AND all the rest of the nodes of the initial linked list from the node the htable should end to the end of the list.
Is any one able to explain why is that happening and how should it be adressed?
Thanks a lot in advance for your time and effort!!!