Alright,
So I have my class set up with five different sort methods (merge, insertion, etc)...
My main method looks like this.
public static void main(String[] args) { int[] randomArray = new int[1000]; System.out.println("Selection Sorted"); selectionSort(randomArray); PrintArray(randomArray);
The print array just prints the sorted array then...
Now, my teacher gave us a little piece of code that looks like this - it's used to time the amount of time it takes to sort the array.
public static void time() { long elapsedtime; Date starttime = new Date(); for (int j = 1; j <= 100; j++) { for (int i = 1; i <= 10000000; i++) { } } Date endtime = new Date(); elapsedtime = endtime.getTime()- starttime.getTime(); System.out.println(elapsedtime); }
Right now it's just a class... but I'm wondering if I can just use it as a method inside my main class that does the sorting of the arrays.
I'm not sure how to implement that class so that when an array goes through the sort method it also gets timed...
Thanks