Question: Revise the three programs given below (Example1.java, Example2.java, and Example3.java) to automatically (using a loop) print the run times for at least 6 equally spaced

Revise the three programs given below (Example1.java, Example2.java, and Example3.java) to automatically (using a loop) print the run times for at least 6 equally spaced N values. Choose N values such that all of the run times are more than 1 second. Note: The N values do not need to be the same for all of the algorithms. For example, you may use larger N values for faster algorithms and smaller N values for slower algorithms in order to have run times that are convenient for comparison.

Below is an example of how your output might appear for one of the algorithms:

Revise the three programs given below (Example1.java, Example2.java, and Example3.java) to automatically

Example1.java:

public class Example1 { public static void main(String[] args) { long startTime, stopTime; // For recording start/stop times long x = 0; startTime = System.currentTimeMillis(); for (long i = 0; i

Example2.java:

public class Example2 { public static void main(String[] args) { long startTime, stopTime; // For recording start/stop times long x = 0; long N = 30000L; startTime = System.currentTimeMillis(); for (long i = 0; i

Example3.java:

public class Example3 { public static void main(String[] args) { long startTime, stopTime; // For recording start/stop times long x = 0; long N = 30000L; startTime = System.currentTimeMillis(); for (long i = 0; i

Example #1 N-10000000, time-31 msec N 20000000, time = 110 msec N-30000000, time109 msec N - 40000000, time172 msec N 50000000, time = 203 msec 60000000, time 266 msec

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!