Ok, I apologize, I'm still lost.
To create a new hash table
Now, here's where I insert the data into the array position.
struct HashTable* newHashTable()
struct HashTable* newguy = (struct HashTable*)malloc(sizeof(struct HashTable));
newguy->store = (int*)calloc(128, sizeof(int));
newguy->taken = (char*)calloc(128, sizeof(char));
newguy->numItems = 0;
newguy->arrayLength = 128;
Can someone show me where I modify those two in order to get this working with separate chaining instead of quadratic probing?
void insert(struct HashTable* h, char dictword)
int hashValue = hashFunction(h, dictword);
/* Find a spot to put the new value by quadratic probing */
position = hashValue;
/* Keep looking for a spot until we find one,
even if that spot has had lazy deletion done to it. */
for(i=1; h->taken[position] == FULL; i++)
/* If we couldn't find a spot to place the
item make the hash table bigger. */
if(i > h->arrayLength)
/* After expanding the table, we need to find the updated hash value
for the item we're inserting, and start the probe over */
hashValue = hashFunction(h,dictword);
/* Quadratic Probing */
offset = i*i;
// Mod by the array length to make sure that we're within the array. */
position = (hashValue + offset) % h->arrayLength;
h->store[position] = dictword;
h->taken[position] = FULL;
// If the table has become too full, expand it.
if((double)h->numItems / (double)h->arrayLength > THRESHOLD)