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

please do the the rehash method. r Linear Probing Hash Table public class Hashta

ID: 3830362 • Letter: P

Question

please do the the rehash method.

r Linear Probing Hash Table public class Hashtable private int currentsize, max Size public Pair map null stores hash table elements Constructor public Hashtable capacity) currentSize 0; maxsize capacity map new Pa for Cinti 0; i maxSize i++) map Cil null Function to check if hash table is empty public boolean is EmptyO return getSize 0; Function to get size of hash table public int getsize return currentsize; Function to check if hash table is full o public boolean isFullO return currentsize max Size

Explanation / Answer

Hi, Please find my implementation.

please let me know in case of any issue.

public void rehash(){
  
   maxSize = 2*maxSize;

   Pair[] newMap = new Pair[maxSize];
  
   // rehashing old values
   for(int i=0; i<currentSize; i++){
       Pair pair = map[i];
       int key = hash(pair.getKey());
       newMap[key] = pair;
   }

   map = newMap;
}