Print each index value in the hash table followed by all the key fields (names) of the entries stored at that index. code example

Example: Print each index value in the hash table followed by all the key fields (names) of the entries stored at that index.

void insert(string s)
    {
        //Compute the index using the hash function
        int index = hashFunc(s);
        //Search for an unused slot and if the index will exceed the hashTableSize then roll back
        while(hashTable[index] != "")
            index = (index + 1) % hashTableSize;
        hashTable[index] = s;
    }

Tags:

Misc Example