Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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