0

i have a Hash table data structure,all the functions works fine but,lookUp function doesn't work properly(it returns the position at which the element is in)

public int lookUp(T key){
    int x =0;
    boolean found = false;
    while(Key[place]!=null){
        if(Key[place] == key){
            found = true;
            break;
        }
        place =(place +probingLinear(x))%v;
        x++;
    }
    if(found)
        return place;
    else
        return -1;
}

Key with capital (K) is an array of type Object,key with small (k) is the element - its type is generic- i search its position , when i add a number like 1 and search for it , it returns its right position which will be in our example 1,but when i add a big number like 3525,it return -1 which means it can't find it.

Notice : the add function works in Integers as : number % Size of array(in our example 3525 : its position 9). Can any one help me why this happen?

Another Notice : 3525 % 12 = 9,it means its in the 9 position in array and when i return Key[9] it gives me 3525 thats mean it does exist, so why Look Up doesn't work ????

0 Answers0