Question
I'm running into trouble implementing a chained hashtable using interface and generics. I need to be implementing the following interface: public interface HashTable { public
I'm running into trouble implementing a chained hashtable using interface and generics. I need to be implementing the following interface:
public interface HashTable
public void add(K key, V value);
public V remove(K key);
public V lookup(K key);
public Object[] getValuesList(); public V[] getSortedList(V[] list); public void printReport();
}
Here is the code I have:
import java.util.ArrayList; import java.lang.Math;
public class Hashtbl/* implements HashTable*/
public V remove(K key) { String a = key.toString(); char[] b = a.toCharArray(); int index= additiveHashing(b,numBuckets); HashNode
public V lookup(K key) { String a = key.toString(); char[] b = a.toCharArray(); int index= additiveHashing(b,numBuckets); HashNode
@Override public void printReport() { // TODO Auto-generated method stub } public Object[] getValuesList(){ // TODO } */ public static void main(String[] args) { Hashtbl
public class HashNode
Can you please fix this code so that it properly implements all the methods in the first interface? I beleive they should all work, but I need help finishing getSortedList(V[] list), getValuesList(), and printReport().
The printReport() method should print to the console the following statistics:
The Load Fator, that is, the ratio of used to total number of buckets.
The longest chain in the table, that is, the maximum number of collisions for a particular bucket.
The Density Factor, that is, the ratio of elements stored elements to total number of buckets.
The Chanining Factor, that is, the average length of any chain in the table.
The V[] getSortedList(V[] list) method should return a sorted list with all the elements in the array.
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