Question: Implement HashLinkedList, which is a simple version of the singly linked list class for the buckets of the hash table. You can start from the
Implement HashLinkedList, which is a simple version of the singly linked list class for the buckets
of the hash table. You can start from the linked list implementation provided on the course web
site ( Exercises 3) as a guide. In particular, implement the methods
add(K,V), remove(K), removeFirst(), getListNode(K).
Note that you will need to modify the given singly linked list code to use it in your hash table. In
particular, the HashLinkedList
E in SLinkedList
/It's implemented in java!!!!!
//I've seen some answers on chegg, but they are wrong
//please, dont copy and paste answers already on chegg
public class HashLinkedList{ /* * Fields */ private HashNode head;
private Integer size;
/* * Constructor */
HashLinkedList(){ head = null; size = 0; }
/* *Add (Hash)node at the front of the linked list */
public void add(K key, V value){ // ADD CODE BELOW HERE
// ADD CODE ABOVE HERE }
/* * Get Hash(node) by key * returns the node with key */
public HashNode getListNode(K key){ // ADD CODE BELOW HERE
// ADD CODE ABOVE HERE }
/* * Remove the head node of the list * Note: Used by remove method and next method of hash table Iterator */
public HashNode removeFirst(){ // ADD CODE BELOW HERE
// ADD CODE ABOVE HERE return null; //CODE STUB.. REMOVE THIS LINE }
/* * Remove Node by key from linked list */
public HashNode remove(K key){ // ADD CODE BELOW HERE
// ADD CODE ABOVE HERE return null; // removing failed }
/* * Delete the whole linked list */ public void clear(){ head = null; size = 0; } /* * Check if the list is empty */
boolean isEmpty(){ return size == 0? true:false; }
int size(){ return this.size; }
//ADD YOUR HELPER METHODS BELOW THIS
//ADD YOUR HELPER METHODS ABOVE THIS
}
Implement HashLinkedList, which is a simple version of the singly linked list class for the buckets of the hash table. You can start from the linked list implementation provided on the course web site (Exercises 3) as a guide. In particular, implement the methods add(K, V), remove(K), removeFirstOI, getListNode (K)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
