Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Modify the hashFunction method ( from the previous module ) . 1 Refactor the method name to hashFunction 2 . 2 Return 1 plus the
Modify the hashFunction method
from the previous module
Refactor the method name to hashFunction
Return
plus the floor modulus of the hash code and the capacity minus
which excludes
from the output range.
This becomes your secondary hash function.
B A private hashFunction
method which takes a key parameter.
Define a salt which is a string literal containing your full name, then concatenate the salt with the given key.
Compute a hash code from the salted key above using a cryptographic hash function.
i Either call a java.security.MessageDigest algorithm or translate a published algorithm from pseudocode.
ii Use a cryptographic hash function which isn
t compromised, such as SHA
Return that hash code modulo the capacity as an index, using the floor modulus instead of the modulus operator.
This becomes your primary hash function.
C Modify the put and get methods
from the previous module
Use your primary hash function and double hashing with your secondary hash function instead of linear probing.
This replaces linear probing with double hashing, which is equivalent to linear probing with a deterministic but variable
offset based on the key from
to capacity minus
instead of a constant offset of
page
RD QUARTER: REHASHING
J Modify the following private fields:
Reinitialize the initial capacity
from the previous module
to an odd prime number between
and
A static constant floating point number for the load factor bound, initialized to
K Still in the HashTable class
not in the DataTable interface
override the loadFactor method:
Return the ratio of the size plus the contamination to the capacity. This adds the contamination to the numerator.
Don
t use integer division. Use floating point division.
L A private rehash method.
Keep a backup reference to the old array which the array field currently references.
Reassign the array field to reference a new array with a length equal to the new capacity.
Reinitialize the size, fingerprint, and contamination to
Don
t call the clear method.
For each row in the old array
skipping nulls and tombstones
call put and pass it the corresponding key and list of fields,
which rehashes that row into the new array. Don
t use the table
s iterator.
When the method terminates, the backup reference becomes unreachable, so the old array is garbage collected.
M Modify the put method.
Before returning from a miss, if the load factor exceeds the load factor bound, dynamically expand the array.
i Reassign the capacity field to be the next odd prime number which is at least twice the previous, either by generating
it using an original algorithm or by retrieving it from a static constant array of eligible primes.
ii Call the rehash method.
TH QUARTER: SET THEORY OPERATIONS
N In the Table interface, a default union method which takes another table parameter
referred to as that table
If this table and that table don
t have equal degrees, throw an illegal argument exception.
For each row in that table, call put on this table and pass it the corresponding key and list of fields from that table.
O In the Table interface, a default intersect method which takes another table parameter
referred to as that table
If this table and that table don
t have equal degrees, throw an illegal argument exception.
For each row in this table, if that table doesn
t contain the corresponding key, add it to a list of keys to be removed.
Then for each key in the list of keys to be removed, call remove on this table and pass it that key.
P In the Table interface, a default minus method which takes another table parameter
referred to as that table
Repeat like step O above, but when the table does
not doesn
t
contain the corresponding key in step
Q In the Table interface, a default keep method which takes a column parameter
string
and a target parameter
object
Call filter on this table and pass it the given parameters.
Call intersect on this table and pass it the partition which filter returned.
R In the Table interface, a default drop method which takes a column parameter
string
and a target parameter
object
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started