Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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; } }

In this problem, you have to implement (in java) a hash map and observe how different load factor impact the performance of hash . You have been provided a data set for this task is a CSV file (zip- . You have to run the progran for load factor ?-0.85, ?-0.80, data structure. Collisions must be resolved by separate chaining. code.csv) with two columns, namely zipcode and population. ? 0.75 and ? 0.70. Note the number of keys for this problern 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 3. String search(String key): return the population from the hash 4. private void readCsv). This function will read the CSV file and the hashCode method for strings. table for a given ZIP code. insert all the entries into the hash table. Note here keys are the ZIP codes. 5. double average length): Return the average length of the linkedlists. Note the average linkedlists length Where k-number of non- null entries in the table and size is the sum of all the linkedlists lengths. 6. double e average number of co- lisions. Note average collision)-average length-1. Note this averagecollision): return th should not be

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

How are fraud examiners used as expert witnesses?

Answered: 1 week ago

Question

Summarize some human resource management training initiatives.

Answered: 1 week ago