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 SizeExplanation / 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;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.