Question: We discussed in class that different implementations of an abstract data type may result in very different performance. You will test three symbol table implementations
We discussed in class that different implementations of an abstract data type may
result in very different performance. You will test three symbol table
implementations taught or will be taught in the class by writing a program ie
java class called TimeSymbolTables in the package ds This program should
create three symbol tables, each of a different implementation. Each symbol table
will contain as the key a word read from the input file and as the value the
number of times that word occurs. For each symbol table object, the program will
fill it with the word counts and keeps track of how long that takes using
the algsStopwatch class see page of the book for how to use the class
After filling each table, the program should print out the time elapsed as
determined by the algsStopwatch.
The program should consist of the following steps:
Create a String array of the words read from a file details will be given
later
Create three symbol table objects using the following classes found in the
algs package:
SequentialSearchST this is the implementation of linkedlistbased
symbol table
BinarySearchST this is the implementation of the symbol table
based on doing a binary search on ordered arrays
BST this is the implementation of the symbol table based on binary
search trees; you may not have learned it yet but this doesnt prevent
you from finishing this assignment as it supports the same methods
as the previous two
Write a loop for each of the symbol table objects in which the code iterates
through the String array created in Step adding to and updating the word
counts in the symbol table. Just before each loop, create
a Stopwatch object. Just after the bottom of each loop, use
the elapsedTime method to get and print the amount of time the loop
takes.
Output the times that the word it occurs in the file, ie output the
frequency of the word it as recorded in an arbitrary one of the three
symbol tables the frequencies in all the three symbol tables should be the
same
You should format the output like the following:
SequentialSearchST: X seconds
BinarySearchST: Y seconds
BST: Z seconds
The word it occurs W times
Reading input from file
The words should be read from a file and the file name is specified as an
argument from the command line. For example, in order to read the words from a
file named datatinyTaletxt one may run your program from command line as
follows:
java dsBalanced datatinyTaletxt
To read the words from the file, you should add the following two lines at the
start of your main function:
In in new Inargs;
String a inreadAllStrings;
After that, you will go over each string in the array and do as specified.
Notice: On DL there is a document Contents Misc Eclipseprogramarguments about running your program from Eclipse while also specifying a file
path. This way, you can use the debugging features eg set breakpoints and
inspect variables provided by Eclipse.
Additional tips
You can test your program on the text files such as datatinyTaletxt
or datataletxt already provided. You should see differences in the times.
Notice that when grading your program, a similar but different text file will
be used.
Submission instructions
Make sure that the program is in the ds package and that your name appears
in comments at the top of the program. Submit only the
TimeSymbolTables.java file into the DL slot provided.
You must use the algsIn class in for input and the algsStdOut class for
output. Do NOT use the Scanner or File Java classes for input. Do NOT use
System.out for output.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
