I am trying to figure out how to convert an add method of a hash table class implemented with quadratic probing as a collision solution method to use coalesced hashing instead. I know that it has something to do with linked lists however because I am a newbie with hash tables I am not sure where to start.
Here is the add method in question,
public boolean add(AnyType x) {
int currentPos = findPos(x);
if (isActive(array, currentPos))
return false;
if (array[currentPos] == null)
occupied++;
array[currentPos] = new HashEntry(x, true);
currentSize++;
modCount++;
if (occupied > array.length / 2)
rehash();
return true;
}
If anybody could show me how this method could be converted to use coalesced hashing I would greatly appreciate it.