Ok, I apologize, I'm still lost.
To create a new hash table
Code:
struct HashTable* newHashTable()
{
int i;
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;
return newguy;
}
Now, here's where I insert the data into the array position.
Code:
void insert(struct HashTable* h, char dictword)
{
int hashValue = hashFunction(h, dictword);
int position;
int offset;
int i;
/* 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)
{
expandTable(h);
/* 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);
i=0;
}
/* 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;
h->numItems++;
// If the table has become too full, expand it.
if((double)h->numItems / (double)h->arrayLength > THRESHOLD)
expandTable(h);
}
Can someone show me where I modify those two in order to get this working with separate chaining instead of quadratic probing?