Question
Efficiency of Array vs. ArrayList-- Use JAVA to implement the operations Using the list operations fill, increment, and search, investigate whether arrays or ArrayLists are
Efficiency of Array vs. ArrayList-- Use JAVA to implement the operations
Using the list operations fill, increment, and search, investigate whether arrays or ArrayLists are faster, or whether they are about the same for int and float values. This will also test times to generate both int and float random numbers as well as the time cost of automatic expansion of an ArrayList. Remember: int and float are used in simple arrays, Integer and Float are used in the ArrayList. All results will be written to a single file named P3Output.txt (Hint open the file for append)
The program has one class. Main calls methods for each of the operations (fill and increment ). The methods each do their own timing and output.
Input / output
This program has no input. Output goes to the file, you may also wish to display it on the screen for convenience. The numeric values must be formatted and the times must be in the same scale.
Output format as below:
int array wall clock : xxx.xxxx seconds
int ArrayList wall clock : xxx.xxxx seconds
int array CPU time : xxx.xxxx seconds
int ArrayList CPU time : xxx.xxxx seconds
float array wall clock : xxx.xxxx seconds
float ArrayList wall clock : xxx.xxxx seconds
float array CPU time : xxx.xxxx seconds
float ArrayList CPU time : xxx.xxxx seconds
Increment elements in the list:
int array wall clock : xxx.xxxx seconds
int ArrayList wall clock : xxx.xxxx seconds
int array CPU time : xxx.xxxx seconds
int ArrayList CPU time : xxx.xxxx seconds
float array wall clock : xxx.xxxx seconds
float ArrayList wall clock : xxx.xxxx seconds
float array CPU time : xxx.xxxx seconds
float ArrayList CPU time : xxx.xxxx seconds
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