Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 2 Lnai 9285

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Joao Gama ,Alipio Jorge ,Carlos Soares

1st Edition

3319235249, 978-3319235240

More Books

Students also viewed these Databases questions