Listing 27.1 MyMap.java public interface MyMap { /** Remove all of the entries from this map */ public void clear(); /** Return true if the specified key is in the map */ public boolean containsKey(K...

1 answer below »
Create a new concrete class that implements MyMap (Listing 27.1) using open addressing with quadratic probing. For simplicity, usef(key) = key % sizeas the hash function, where size is the hash-table size. Initially, the hash-table size is 4. The table size is doubled whenever the load factor exceeds the threshold (0.5). Write a driver program to test your class.
attached is lifting 27.1


Listing 27.1 MyMap.java public interface MyMap { /** Remove all of the entries from this map */ public void clear(); /** Return true if the specified key is in the map */ public boolean containsKey(K key); /** Return true if this map contains the specified value */ public boolean containsValue(V value); /** Return a set of entries in the map */ public java.util.Set<>> entrySet(); /** Return the first value that matches the specified key */ public V get(K key); /** Return true if this map contains no entries */ public boolean isEmpty(); /** Return a set consisting of the keys in this map */ public java.util.Set keySet(); /** Add an entry (key, value) into the map */ public V put(K key, V value); /** Remove the entries for the specified key */ public void remove(K key); /** Return the number of mappings in this map */ public int size(); /** Return a set consisting of the values in this map */ public java.util.Set values(); /** Define inner class for Entry */ public static class Entry { K key; V value; public Entry(K key, V value) { this.key = key; this.value = value; } public K getKey() { return key; } public V getValue() { return value; } @Override public String toString() { return "[" + key + ", " + value + "]"; } } }
Answered 3 days AfterApr 30, 2021

Answer To: Listing 27.1 MyMap.java public interface MyMap { /** Remove all of the entries from this map */...

Kshitij answered on May 04 2021
156 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here