Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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); EntrycurrentEntry = 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started