Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using the following HashMapeK, V> class add: A method (void deletelk key) which

ID: 3739068 • Letter: U

Question

Using the following HashMapeK, V> class add: A method (void deletelk key) which deletes the key-value pair with the given key from the map if it is present. Note: Do not implement map resizing at this point. public class HashMapeK, Vs implements JRK, > private static final ?DE DEFAULT-NUM-BUCKETS 13; a Linked List of list of key-value pairs private Linked ListeKVPCK, V>21 buckets; private UEN; private int factor; public MutashMaalot M, iot factor] thisfacter- factor; this.bucket = new LinkedList[ M ]; for int i-ois bucket&Lenstbi; buckets[i] = new LinkedList

Explanation / Answer

Here is code for delete the hashmap value

import java.utl.LinkedList;
public class HashMap(K,V) implements IKVStore(K,V){
private static final int DEFAULT_NUM_BUCKETS=13;
private LinkedList <KVP<K,V>> [] buckets;
private int N;
private int factor;
  
public MyHasMap(int M, int factor){
this.factor=factor;
this.buckets=new LinkedList[M];
for(int i=0;i<buckets.length ; i++){
buckets[i]=new LinkedList<>();
}
  
N=0;
  
}
public MyHashMap(){
this(DEFAULT_NUM_BUCKETS,2);
}
  
public void delete(K key){
HashMap newmap = new HashMap();   
newmap.remove(key);
}
}