Question: Consider a Hashtable class that implements the table as an array of linked lists, and therefore uses separate chaining to resolve collisions: (Note that the

Consider a Hashtable class that implements the table as an array of linked lists, and therefore uses separate chaining to resolve collisions: (Note that the keys are integers, not generic). public class HashTable \{ private Node[] table = null; // constructor public HashTable(int capacity) \{ table = new Node[capacity]; \} // your addKey code would go here. public int hashCode(int key) {// get a hashcode from the key return key % table.length; // hashing function \} 3 This class is used to implement the linked lists: public class Node \{ private int key =0; private Node link = null; public Node(int k, Node I) { key=k; link=l; } public int getKey (){ return key; } public Node getLink (){ return link; } public void setLink(Node newLink) this.link = newLink; } 3 Write the addKey method that would allow new data to be added to the hashtable. You do not have to be concerned about detecting duplicate keys. public void addKey(int key)\{ // your method code here 3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
