T
Totti
Hi all, i am trying to do a quadratic hashing but i am having some
difficulties probably because i am not in the right logic.using this
code:
public void insert(DataItem item)
{
int key = item.getKey();
int hashVal = hashFunc(key);
int x = 0;
while(arr[hashVal] != null )
{
hashVal = hashVal + (int) Math.pow(x,2); // go to next cell
hashVal %= size; // wraparound if necessary
x++;
}
arr[hashVal] = item;
}
thi seems working ok untill something has taken the slot meant to be
the item's i am inserting at this moment, so it has to go as x + (1^2)
if empty, if not x+(2^2) *** ^ means to the power of
so on and so forth, the x++ shall occur only if the previous x could
not been committed.
would you please help?
it is wrapping arround but the problem is the x++ i think, i dont know
how to fix it, i am pretty new to java,
i ll appreciate any help and thanks in advance
difficulties probably because i am not in the right logic.using this
code:
public void insert(DataItem item)
{
int key = item.getKey();
int hashVal = hashFunc(key);
int x = 0;
while(arr[hashVal] != null )
{
hashVal = hashVal + (int) Math.pow(x,2); // go to next cell
hashVal %= size; // wraparound if necessary
x++;
}
arr[hashVal] = item;
}
thi seems working ok untill something has taken the slot meant to be
the item's i am inserting at this moment, so it has to go as x + (1^2)
if empty, if not x+(2^2) *** ^ means to the power of
so on and so forth, the x++ shall occur only if the previous x could
not been committed.
would you please help?
it is wrapping arround but the problem is the x++ i think, i dont know
how to fix it, i am pretty new to java,
i ll appreciate any help and thanks in advance