Question: this is about hashtable open addressing and i have no idea why my method only pass on 'removequad'. Could you please make this method works
this is about hashtable open addressing and i have no idea why my method only pass on 'removequad'.
Could you please make this method works on linear and doublehash?
public boolean remove(K key) { int initialHash = hash(key); int offset = 0; int index = getNextIndex(key, offset); Entry currentEntry = table[index]; while(currentEntry != null && currentEntry.getActive()) { if(currentEntry.getKey().equals(key)) { currentEntry.setActive(false); size--; return true; } offset++; if(offset >= capacity) { throw new RuntimeException("Infinite Loop"); } index = getNextIndex(key, offset); currentEntry = table[index]; } return false; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
