Question: import java.util.function.Function; public class DoubleHashTable implements OpenAddressTable { private int [ ] table; private int size; private Function h 1 ; private Function h 2
import java.util.function.Function;
public class DoubleHashTable implements OpenAddressTable
private int table;
private int size;
private Function h;
private Function h;
public DoubleHashTableint size, Function h Function h
if size
throw new IllegalArgumentExceptionTable size must be greater than ;
this.size size;
this.table new intsize;
this.h h;
this.h h;
@Override
public double loadFactor
int count ;
for int value : table
if value
count;
return double count size;
@Override
public void insertint value
if value
throw new IllegalArgumentExceptionValue must be nonnegative";
int probe ;
int index hashvalue probe;
while tableindex
probe;
index index probe happlyvalue size;
tableindex value;
@Override
public int findint value
int index happlyvalue;
int step happlyvalue;
int probe ;
while tableindex && tableindex value && probe size
index index step size;
probe;
return probe size && tableindex value index : ;
@Override
public int hashint key, int probenumber
Double hashing using h and h functions
int result happlykey probenumber happlykey size;
return result result size : result;
@Override
public String toString
StringBuilder result new StringBuilder;
for int i ; i size; i
if tablei
int index i; Use the current index directly
if resultlength
result.append;
result.appendindexappendappendtablei;
return result.toString;
public static void mainString args
Function h key key ;
Function h key key ;
DoubleHashTable t new DoubleHashTable h h;
tinsert;
tinsert;
tinsert;
tinsert;
System.out.printlnttoString;
Expected output:
Fix my code as the current output is: and I cannot seem to figure out how to do it I really need it
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
