
Describe (by inspection or graphing) how the time to run put (k, v) increases as the load factor of the hash table increases and provide reason to justify your observation. void experiment interpret() must perform the following: (a) Create a hash map of initial capacity 100 (b) Create a local Java.util ArrayList (say, data) of 150 random pairs. f) Ensure that your hash map functions correctly. e) Run remove (k) on the first 25 keys, followed by get (k) on each of the 50 keys. d) Run get (k) on each of the 50 elements in data. c) Add all 50 entries from the data array to the map, using the put (k, v) method, of course. b) Heads-up: you should never use a non-prime hash table size in practice but do this for the purposes of this experiment. Create a MyHashMap object using 100 as the initial capacity (N) of the hash map. void validate() must perform the forlowing: a) Create a local Java.util ArrayList (say, data) of 50 random pairs. Class HashMapDriver This class should include the following static void methods: 1. If any put (k, v) takes an excessive amount of time, handle this with a suitable exception. each invocation of get (k), put (k, v), and remove (k) should print the time used to run the method. the number of items in the bucket storing v Additionally,. the number of keys that resulted in a collision. the number of elements in the table after the method has finished processing (k, v) entry. For the purpose of output presentation in this assignment, equip the class to print the following information each time the method put (k, v) is invoked. You may use Java's ArrayList as the buckets to store the entries. The class must use separate chaining to resolve key collisions. Class MyHashMap Write a concrete class named MyHashMap that implements AbsHashMap. remove (k) Removes from the map the entry with key equal to k, and returns its value if the map has no such entry, then it returns null.
get (k) Put (k, v) if the map does not have an entry with key k, then adds entry (k, v) to it and returns null else replaces with v the existing value of the entry with key equal to k and returns the old value. The class must include the following abstract methods: size() Returns the number of entries in the map isEmpty() Returns a Boolean indicating whether the map is empty Returns the value v associated with key k, if such an entry exists otherwise return null.
LIQUID WAR HANDLING COLLISIONS MOD
Abstract Class AbsHashMap This abstract class models a hash table without providing any concrete representation of the underlying data structure of a table of "buckets." (See pages 410 and 417.) The class must include a constructor that accepts the initial capacity for the hash table as a parameter and uses the function h (k)= k mod N as the hash (compression) function.
An override for class Object's compression function public int hashCode (), using any of the strategies covered in section 10.2.1 (Hash Functions, page 411). The value component of the pair may be supplied as a parameter or it may be generated randomly, depending on your choice of the Value type. A constructor that generates a new Entry object using a random integer (key). Your class must include the following methods. Specifically, Key is of type integer, while Value can be any type of your choice. This will be a non-generic implementation. (The ratio λ = n/N is called the load factor of the hash table, where N is the hash table capacity, and n is the number of elements stored in it.) Class Entry Write a class Entry to represent entry pairs in the hash map. In this assignment you will implement a map using a hash table, handling collisions via separate chaining and exploring the map's performance using hash table load factors.