This lab gives you some experience measuring the running time of algorithms.
Download http://www.cs.vassar.edu/~cs102/assign/lab6.zip and import it into your Eclipse workspace.
In the same class as the genRanArray method you wrote for part 1, write a main method to do the following:
Like most high-level languages, Java provides a method to measure the running time of a program. The call to this method is as follows:
The currentTimeMillis method returns an integer of type long, representing the current system time in milliseconds.
Time a particular statement by calling it in between two calls to System.currentTimeMillis() and then subtracting the difference between the times returned by those two calls.
Prepare a terminal window for running the program by executing the following commands (typing return after each one):
cd cd eclipse-workspace/lab6/bin setenv CLASSPATH .:$CLASSPATH
Run the program from the terminal window as follows:
java edu.vassar.cs.cs102.sorts.Sorts 20000 1000000Warning: make sure the size of the array, m, is less than the range n, or your program will never terminate.
Your output should be as follows (user input bolded):
Generating 20000 unique random numbers took 12600 ms Insertion sort took 4293 ms Shell sort took 1826 ms Merge sort took 33 ms Quick sort took 29 msTest your program on large enough data sets to give you an idea of how the running time of each program relates to the size of the data set (warning: generating too large a data set will take a very long time). Recommended maximum size = 20000.
Run your program for your lab instructor when you get it working.
Submit your lab6 directory when you are finished and have tested your program: from a terminal window
cd cd eclipse-workspace submit102 lab6