Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The following private fields: 1 A one - dimensional array of rows, which is the table array. 2 A string for the name, which is
The following private fields:
A onedimensional array of rows, which is the table array.
A string for the name, which is the name of the table itself.
A list of strings for the columns, which are the ordered names of the columns, including the key and the list of fields.
An integer for the degree, which is the number of columns, including the key and the list of fields.
An integer for the size, which is the current number of rows in the table.
An integer for the capacity, which is the maximum number of rows in the table and is always an odd prime number.
An integer for the fingerprint, which is the amortized sum of the hash codes of all rows in the array.
A static constant integer for the initial capacity, initialized to an odd prime number between and
B A ary constructor which takes a name parameter string and a columns parameter list of strings
Initialize the name field using the corresponding parameter.
Initialize the columns field using an immutable copy of the corresponding parameter.
Initialize the degree field based on the quantity of columns.
Call the clear method.
C A public clear method.
Initialize the capacity field to the initial capacity constant.
Initialize the array field with a length equal to the capacity.
Initialize the size field to
Initialize the fingerprint to
D Public methods for the following properties:
The degree, size, capacity, name, and columns methods which return the corresponding fields.
The hashCode method which returns the fingerprint.
The equals method which takes an object parameter.
i If the parameter is a table of any type not just a hash table and has the same fingerprint as this table, return true.
ii Otherwise, return false to indicate the parameter is unequal to this table.
E A private hashFunction method which takes a key parameter string
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 noncryptographic hash function.
i Either translate a published algorithm from pseudocode or design your own algorithm.
ii Use either a polynomial rolling hash function or a noteworthy noncryptographic hash function.
Return that hash code modulo the capacity as an index, using the floor modulus instead of the modulus operator.
ND QUARTER: PUT, GET, LINEAR PROBING
F A public put method which takes a key parameter string then a list of fields parameter list of objects
If the degree of the given row doesnt match the degree field of the table, throw an illegal argument exception.
Create a new row composed of the key parameter and an unmodifiable view of the list of fields parameter.
Use your hash function and linear probing to find an old row with the given key.
On a miss, set the new row at the probed index, increase the size by update the fingerprint, then return null.
On a hit, replace the old row at the probed index with the new row, update the fingerprint, then return the old list of fields.
On an unexpected fallthrough when linear probing because the array is full, throw an illegal state exception.
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