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.
A public get method which takes a key parameter.
Use your hash function and linear probing to find an old row with a key equal to the given parameter.
On a hit, return the old list of fields.
On a miss, return null.
On an unexpected fallthrough when linear probing because the array is full, throw an illegal state exception.
H A public remove method which takes a key parameter and throws an unsupported operation exception until next module
RD QUARTER: ITERATOR
I A public iterator method which returns an iterator of rows, using the following anonymous class implementation:
An integer field for the current index in the array, initialized to skipping nulls
A hasNext method which returns true if the current index skipping nulls is less than the capacity or false otherwise.
A next method which returns the next row.
i If hasNext returns false, throw a no such element exception.
ii Otherwise, return the row at the current index.
iii Before the method terminates, increase the current index by skipping nulls
After mutating the current index but before using it to access a row, while the array has a null at the current index,
increase it by Thus each iteration yields a row, skipping nulls, and the number of iterations equals the size.
TH QUARTER: FILTER PARTITION
J A public toString method.
Return an unsorted view of the table by calling toTabularView.
K In the Table interface, a default filter method which takes a column parameter string and a target parameter object
If the table columns dont contain the given column, throw an illegal argument exception.
If the given target is null, throw an illegal argument exception.
Create a partition a new table of some type, preferably a hash table by calling the ary constructor
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