Link Main Question Https Wwwcheggcom Homework Help Questions Answers Hash Tables Java Prov Q37281934

link to the main question:

https://www.chegg.com/homework-help/questions-and-answers/hash-tables-java-provided-four-items-question-e-1-dictionaryinterfacejava-2-hasheddictiona-q37281962?trackid=kX6ehlfT

HashedDictionary.java part 2:

/*

* We have completed this method for you, and you do not

* have to modify it. Precondition: checkIntegrity has beencalled.

*/

   private intquadraticProbe(int index, K key)

   {

boolean found = false;

int availableIndex = -1; // Index of firstavailable location (from which an entry was removed)

int increment = 1; // For quadratic probing

  

while ( !found && (hashTable[index] !=null) )

{

   if ((hashTable[index] !=null) && (hashTable[index] !=AVAILABLE))

   {

if (key.equals(hashTable[index].getKey()))

   found = true; // Key found

else // Follow probe sequence

{

   index = (index + increment) % hashTable.length; //Quadratic probing

   increment = increment + 2; // Odd values forquadratic probing

}

   }

  

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.