Hello there all,
I wanted to have a question answered. I need to know how we would be able to Insert into a hash table with linear probing. I have half of the code done(where Insert does not require collisions.)
The second half I cannot get the algorithm for. Please look through this. A rough pseudocode will do. Thank you in advance.
Code:bool HashTable::Insert(const string &name, const string &address) // insert an address with associated name { // unsigned int key = Mask(Hash(name)); unsigned int key = 0; // if the element given by the hash function is empty // then set the name and address to this element. if (ptr[key].GetName()=="nil"){ ptr[key].SetName(name); ptr[key].SetAddress(address); return true; } // else, increment the array element one and try to insert there else { } }



LinkBack URL
About LinkBacks


