To answer my question follow the instructionsare below in bu

To answer my question, follow the instructionsare below in bulletpoints.

Hash Collision Write code to insert an item AFTER a hash collision Pass the variable a key to the method liashFunction and assign the result to numslot Write a while loop that starts at slot index numslot of array hasharray and increments numslot until it finds an open slot Insert the variable akey into the array hasharray at the index slot found by the loop An index/slot is occupied when hasharray[index].charAt(0) != \' \' is true (that is a space \'\') An index/slot is open when hasharray[index].charAt(0) != \' \' is false (that is a space \'\') Do not declare or initialize any variables or write hashFunction, I will do that Implement the instructions above by placing your Code here:

Solution

Edit: Please modify according to your needs, because doesn\'t clearly define parameter for function. I\'m assuming you\'re passing array and numslot number to function as well.

As per your requirement, I think this will suffice

hashfunction(int akey, int numslot, int hashArray[]) {

// define

i = numslot;

while ((i+1)%size != numslot) {

     if(hasharray[i].charAt(0)==\'\') {

        hasharray[i] = akey;

        break;

     } else {

        i = (i+1)%size;

     }

}

}

To answer my question, follow the instructionsare below in bulletpoints. Hash Collision Write code to insert an item AFTER a hash collision Pass the variable a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site