Question: Here is heapMap code: package hashMap; import java.util.*; import java.io.*; /eed to import more packages public class hashMap{ int m; //m size of the table

 Here is heapMap code: package hashMap; import java.util.*; import java.io.*; /eed

Here is heapMap code:

package hashMap; import java.util.*; import java.io.*; /eed to import more packages public class hashMap{ int m; //m size of the table int p; // prime m

[] hashtable; //Constructor. //Pick a universal hash function here and called readCSV() public hashMap(double alpha){ m= (int)(Math.ceil((n/alpha)))+1; m=Math.abs(m); @SuppressWarnings("unchecked") LinkedList[] table= new LinkedList[m]; hashtable=table; p=getPrime(m+1, 2*m-1); }// Complete this hashMap method. //return an index of the table public int universalHash(String key) { return 0; }//Complete universalHash method. Note return value is dummy. // insert would call universalHash public void insert(String key, String data) { }// Complete this insert method public String search(String key){ return "00"; }//complete the search method. Note return value is dummy //Return a prime number between [x,y] public int getPrime(int x, int y){ int p=4; while(isPrime(p)==false){ p=rand(x,y); } return p; } //First read the csv file and then insert data into the table. //This method should be called with the contructor. public void readCsv()throws FileNotFoundException,IOException{ }//complete the search method. //Locally called by getPrime() private boolean isPrime(int q){ int max=(int) Math.ceil(Math.sqrt(q)); for(int i=2; i

-----------------------------------

package hashMap; public class hashNode{ String key; String data; hashNode next; //constructor public hashNode(String k, String d){ key=k; data=d; } }

---------------------

csvfile

Zip Code ZCTA,Population 1001,16769 1002,29049 1003,10372 1005,5079 1007,14649 1008,1263

In this problem, you have to implement (in java) a hash map and observe how different load factor impact the performance of hash data structure. Collisions must be resolved by separate chaining You have been provided a data set for this task is a CSV file (zip- code.csv) with two columns, namely zipcode and population. You have to run the program for load factor ? = 0.85, ? = 0.80 a - 0.75 and a -0.70. Note the number of keys for this problem are fixed (see the data file). Therefore the table size is determined by the load factor Your class should be called hashMap.java and must include the follow- ing methods 1. void insert (String key, String data) new entries in the table using Universal hash function (the one we saw in the class) 2. int universalHash(String key): return the hash value of the key. Note keys are of type strings, thus they must be prehashed using the hashCode method for strings 3. String search(String key): return the population from the hash table for a given ZIP code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!