Question: i need help writing a class from the information below Constructor Detail ConcordanceDataStructure public ConcordanceDataStructure (java.lang.String test, int size) Constructor for testing purposes The string

i need help writing a class from the information below

Constructor Detail

ConcordanceDataStructure

public ConcordanceDataStructure(java.lang.String test, int size) 

Constructor for testing purposes The string will be "Testing" and the int will be the size of the hash table. This is used only for testing.

Parameters:

test - the string "Testing"

size - the size of the hash table

ConcordanceDataStructure

public ConcordanceDataStructure(int num) 

This constructor takes in an integer which represents the estimated number of words in the text. Determine the size of the table by using a loading factor of 1.5 and a 4K+3 prime. Example if you estimated 500 words, 500/1.5 = 333. The next 4K+3 prime over 333 is 347. So you would make the table a length of 347.

Parameters:

num - the estimated number of words in the text

Method Detail

getTableSize

public int getTableSize() 

Returns the size of the ConcordanceDataStructure (number of indexes in the array)

Specified by:

getTableSize in interface ConcordanceDataStructureInterface

add

public void add(java.lang.String term, int lineNum) 

Use the hashcode of the ConcordanceDataElement to see if it is in the hashtable. If the word does not exist in the hashtable - Add the ConcordanceDataElement to the hashtable. Put the line number in the linked list If the word already exists in the hashtable 1. add the line number to the end of the linked list in the ConcordanceDataElement (if the line number is not currently there).

Specified by:

add in interface ConcordanceDataStructureInterface

Parameters:

term - the word to be added/updated with a line number.

lineNum - the line number where the word is found

showAll

public java.util.ArrayList showAll() 

Description copied from interface: ConcordanceDataStructureInterface

Display the words in Alphabetical Order followed by a :, followed by the line numbers in numerical order, followed by a newline here's an example: after: 129, 175 agree: 185 agreed: 37 all: 24, 93, 112, 175, 203 always: 90, 128

Specified by:

showAll in interface ConcordanceDataStructureInterface

Returns:

an ArrayList of Strings. Each string has one word, followed by a :, followed by the line numbers in numerical order, followed by a newline.

getWords

public java.util.ArrayList getWords(int index) 

Returns an ArrayList of the words at this index [0] of the ArrayList holds the first word in the "bucket" (index) [1] of the ArrayList holds the next word in the "bucket", etc. This is used for testing

Specified by:

getWords in interface ConcordanceDataStructureInterface

Parameters:

index - location within the hash table

Returns:

an Arraylist of the words at this index

getPageNumbers

public java.util.ArrayList> getPageNumbers(int index) 

Returns an ArrayList of the Linked list of page numbers for each word at this index [0] of the ArrayList holds the LinkedList of page numbers for the first word in the "bucket" (index) [1] of the ArrayList holds the LinkedList of page numbers for next word in the "bucket", etc. This is used for testing

Specified by:

getPageNumbers in interface ConcordanceDataStructureInterface

Parameters:

index - location within the hash table

Returns:

an ArrayList of the Linked list of page numbers for each word at this index

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!