Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

To answer my question, follow the instructionsare below in bulletpoints and begi

ID: 3572410 • Letter: T

Question

To answer my question, follow the instructionsare below in bulletpoints and begin with the following line of code

numstart = hashFunction(thekey);

Exercise 10.2: Hash Collision Write code to insert an item AFTER a hash collision Pass the variable thekey to the method hashFunction and assign the result to numstart Write a while loop that starts at slot/index numstart of array hasharray and increments numstart until it finds an open slot Insert the variable thekey into the array hasharray at the index slot found by the loop An index slot is occupied when hasharrayl index ].charAt(0) !J'' is true (that is a space An index slot is open when hasharray[ index l.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 Build Exercise Program

Explanation / Answer

numstart = hashFunction(thekey);
  
while(hasharray[numstart].charAt(0) != ' '){
numstart = numstart+1;
}
  
hasharray[numstart] = thekey;

----------------------

as the question doesn't ask anything else other than bullet points then above code is enough otherwise size of hasharray would be required to add a termination and loop around condition in while.

For example:

numstart = hashFunction(thekey);
   len = 0
   while(hasharray[numstart].charAt(0) != ' '){
       numstart = (numstart+1) % MAX_LIMIT_INDEX_OF_HASHARRAY;
      
       len = len + 1;      
       if(len == hasharray.length())
           break;
   }
  
   hasharray[numstart] = thekey;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote