Question: import java.util.Random; public class RuntimeAnalyzer { public static void main ( String [ ] args ) { int totalTime = 0 ; int totalAssignmentStatement =

import java.util.Random;
public class RuntimeAnalyzer {
public static void main(String[] args)
{
int totalTime =0;
int totalAssignmentStatement =0;
long startTime;
long stopTime;
for (int arraySize =5; arraySize <51; arraySize +=5){
for (int i =1; i <=20; i++){
startTime = System.nanoTime();
totalAssignmentStatement += MethodTester.algorithm1(GenerateArray(arraySize));
stopTime = System.nanoTime();
totalTime +=(stopTime - startTime);
}
System.out.println("=Array size "+ arraySize +"=
average assignment statements: "+ totalAssignmentStatement /20.0+
"
Average execution time: "+ totalTime/20.0+"ns ("+ totalTime /20.0/1000000.0+"ms)
");
totalTime=0;
totalAssignmentStatement=0;
}
}
public static int[] GenerateArray (int arraySize)
{
int[] array = new int[arraySize];
//TODO
return array;
}
}

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!