Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN Java Implement a hash table to be an array of HashObject. A HashObject contains a generic object and a frequency count. The HashObject needs

IN Java Implement a hash table to be an array of HashObject. A HashObject contains a generic object and a frequency count. The HashObject needs to override both the equals and the toString methods and should also have a getKey method. We will use linear probing and double hashing. So design the HashTable class to have an indicator parameter in the constructor to set the type of probing will be performed. The HashTable defaults to linear probing. Choose a value of the table size m to be a prime in the range [95500 . . . 96000]. A good value is to use a prime that is 2 away from another prime. That is, both m and m 2 are primes. Two primes (differ by two) are called twin primes. Please find the table size using the smallest twin primes in the given grange [95500 . . . 96000]. Vary the load factor as 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.98, 0.99 by setting the value of n appropriately, that is, n = m. Keep track of the average number of probes required for each value of for linear probing and for double hashing. For the double hashing, the primary hash function is h1(k) = k mod m and the secondary hash function is h2(k) = 1 + (k mod (m 2)).

For the experiment we will consider three different sources of data as follows. You will need to insert HashObjects until the pre-specified is reached, where Data Source 1: each HashObject contains an Integer object with a random int value generated by the method nextInt() in java.util.Random class. The key for each such HashObject is the Integer object inside. Data Source 2: each HashObject contains a Long object with a long value generated by the method System.currentTimeMillis(). The key for each such HashObject is the Long object inside. Data Source 3: each HashObject contains a word from the file word-list\ The key for each such HashObject is the word inside. When you hash a HashObject into a table index, you will need to Compute the hashCode() of the key of the HashObject. Use the hashCode() to perform the linear probing or double hashing calculation. Note that hashCode() can return negative integers. You need to ensure that the mod operation in the probing calculation always returns positive integers.

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

Step: 3

blur-text-image

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

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago