Question
Please write this program in Java language please. Requirements The purpose of this project is to: Gain an understanding of using some of the common
Please write this program in Java language please.
Requirements
The purpose of this project is to:
Gain an understanding of using some of the common Java class library classes
Increase your knowledge of generic classes
Understand performance implications of various data structures we have studied so far.
In order to this create a Java program that uses the generic Java classes ArrayList, LinkedList, HashSet and TreeSet to create a list of 100,000 random Strings. You should use the Random class to create the random strings. Measure the time to:
Populate the structure. That is, add the 100,000 Strings.
As you add the strings to the list, remember the first, middle and last String added.
Search for the first, middle and last String. Perform the search 10,000 times.
Because of the object hierarchy, you only need to write the method that implements steps 1 and 2 once. The main program should create (execute the new) the list to be tested and pass that reference to the method that executes steps 1 and 2.
Use System.currentTimeMillis() to determine the elapsed time for steps 1 and 2 above.
The results should be printed in a simple report as shown below. Submit this output along with an explanation of the results you experience. Your explanation of the results can be very brief. Only a couple of sentences is needed.
A submission that completes the above successfully will be graded as a B. In order to achieve an A, implement the same as above but rather than creating the generic classes using
Sample Output:
Array of String create time (ms) = 36
Array of String First search time (ms): 1
Array of String Middle search time (ms): 3239
Array of String Last search time (ms): 6839
Linked List of String create time (ms) = 16
Linked List of String First search time (ms): 1
Linked List of String Middle search time (ms): 5178
Linked List of String Last search time (ms): 10522
Hash Set of String create time (ms) = 84
Hash Set of String First search time (ms): 4
Hash Set of String Middle search time (ms): 1
Hash Set of String Last search time (ms): 1
Tree Set of String create time (ms) = 90
Tree Set of String First search time (ms): 3
Tree Set of String Middle search time (ms): 1
Tree Set of String Last search time (ms): 2
Optional Output:
Array of Item create time (ms) = 29
Array of Item First search time (ms): 3
Array of Item Middle search time (ms): 3747
Array of Item Last search time (ms): 7904
Linked List of Item create time (ms) = 561
Linked List of Item First search time (ms): 3
Linked List of Item Middle search time (ms): 7125
Linked List of Item Last search time (ms): 12549
Hash Set of Item create time (ms) = 47
Hash Set of Item First search time (ms): 1
Hash Set of Item Middle search time (ms): 1
Hash Set of Item Last search time (ms): 0
Tree Set of Item create time (ms) = 136
Tree Set of Item First search time (ms): 6
Tree Set of Item Middle search time (ms): 2
Tree Set of Item Last search time (ms): 2
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