Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A one - dimensional array of rows, which is the table array. 2 A constant string for the name, which is the name of the

A one-dimensional array of rows, which is the table array.
2 A constant string for the name, which is the name of the table itself.
3 A constant list of strings for the columns, which are the ordered names of the columns, including the key and list of fields.
4 A constant 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 a power of 2.
7 A static constant integer for the initial capacity, initialized to 16.
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.
D Public methods for the following properties:
1 The degree, size, capacity, name, and columns methods which return the corresponding fields.
2 In the Table interface, the isEmpty method which returns true if the size is 0 or false otherwise.
3 In the DataTable interface, the isFull method which returns true if the size equals the capacity or false otherwise.
4 In the DataTable interface, the loadFactor method which returns the ratio of the size to the capacity.
E In the Row record, a key component (string), a fields component (list of objects), and the following features:
1 A public toString method which returns a string in key: fields format based on the corresponding components.
F A public toString method (for development use, replaced by a later version in step T).
1 Pass the array to Arrays.toString and return the resulting string view.
2ND QUARTER: PUT, GET, REMOVE
G 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 Linear search the array to find an old row with the given key.
4 On a hit, replace the old row at its index within the filled region with the new row, then return the old list of fields.
5 On a miss, append the new row to the filled region, increase the size by 1, then return null.
6 Before returning from a miss, if the size equals the capacity, dynamically expand the array.
i Double the capacity field, keeping it a power of 2.
ii Reassign the array field to reference a copy of itself with a length equal to the new capacity.
H A public get method which takes a key parameter.
1 Linear search the array 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.
I A public remove method which takes a key parameter.
1 Linear search the array to find an old row with a key equal to the given parameter.
2 On a hit, replace the old row at its index within the filled region with the last row at the end of the filled region, nullify the
last row at the end of the filled region, decrease the size by 1, then return the old list of fields.
3 On a miss, return null.
page 2/3
J In the Table interface, a default contains method which takes a key parameter.
1 If calling this tables get method returns a non-null result, return true.
2 Otherwise, return false.
3RD QUARTER: FINGERPRINT, ITERATOR
K Modify the following private fields:
1 An integer for the fingerprint, which is the amortized sum of the hash codes of all rows in the array.
L Modify the clear method.
1 Initialize the fingerprint field to 0.
M Modify the public methods for the following properties:
1 The hashCode method which returns the fingerprint.
2 The equals method which takes an object parameter.
i If the parameter is a table of any type (not just a search table) and has the same fingerprint as this table, return true.
ii Otherwise, return false to indicate the parameter is unequal to this table.
N In the Row record, modify the following features:
1 A public hashCode method which returns the hash code of the key xor (exclusive-or) the hash code of the list of fields.
O Modify the put method.
1 On a hit, subtract the hash code of the old row from the fingerprint, and add the hash code of the updated row to it.
2 On a miss, add the hash code of the new row to the fingerprint.
P Modify the remove method.
1 On a hit, subtract the hash code of the removed row from the fingerprint.
Q 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

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

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions