Answered step by step
Verified Expert Solution
Link Copied!

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:
1 A one-dimensional array of rows, which is the table array.
2 A string for the name, which is the name of the table itself.
3 A list of strings for the columns, which are the ordered names of the columns, including the key and the list of fields.
4 An integer for the degree, which is the number of columns, including the key and the list of fields.
5 An integer for the size, which is the current number of rows in the table.
6 An integer for the capacity, which is the maximum number of rows in the table and is always an odd prime number.
7 An integer for the fingerprint, which is the amortized sum of the hash codes of all rows in the array.
8 A static constant integer for the initial capacity, initialized to an odd prime number between 500 and 1000.
B A 2-ary constructor which takes a name parameter (string) and a columns parameter (list of strings).
1 Initialize the name field using the corresponding parameter.
2 Initialize the columns field using an immutable copy of the corresponding parameter.
3 Initialize the degree field based on the quantity of columns.
4 Call the clear method.
C A public clear method.
1 Initialize the capacity field to the initial capacity constant.
2 Initialize the array field with a length equal to the capacity.
3 Initialize the size field to 0.
4 Initialize the fingerprint to 0.
D Public methods for the following properties:
1 The degree, size, capacity, name, and columns methods which return the corresponding fields.
2 The hashCode method which returns the fingerprint.
3 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).
1 Define a salt which is a string literal containing your full name, then concatenate the salt with the given key.
2 Compute a hash code from the salted key above using a non-cryptographic 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 non-cryptographic hash function.
3 Return that hash code modulo the capacity as an index, using the floor modulus instead of the modulus operator.
2ND 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).
1 If the degree of the given row doesnt match the degree field of the table, throw an illegal argument exception.
2 Create a new row composed of the key parameter and an unmodifiable view of the list of fields parameter.
3 Use your hash function and linear probing to find an old row with the given key.
4 On a miss, set the new row at the probed index, increase the size by 1, update the fingerprint, then return null.
5 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.
6 On an unexpected fall-through when linear probing because the array is full, throw an illegal state exception.
A public get method which takes a key parameter.
1 Use your hash function and linear probing to find an old row with a key equal to the given parameter.
2 On a hit, return the old list of fields.
3 On a miss, return null.
4 On an unexpected fall-through 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).
3RD QUARTER: ITERATOR
I A public iterator method which returns an iterator of rows, using the following anonymous class implementation:
1 An integer field for the current index in the array, initialized to 0(skipping nulls *).
2 A hasNext method which returns true if the current index (skipping nulls *) is less than the capacity or false otherwise.
3 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 1(skipping nulls *).
4* 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 1. Thus each iteration yields a row, skipping nulls, and the number of iterations equals the size.
4TH QUARTER: FILTER PARTITION
J A public toString method.
1 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).
1 If the table columns dont contain the given column, throw an illegal argument exception.
2 If the given target is null, throw an illegal argument exception.
3 Create a partition (a new table of some type, preferably a hash table) by calling the 2-ary constructor

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

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions

Question

What is the Java key word that encapsulates data inside an object?

Answered: 1 week ago