I wrote couple sorting algorithm. I want to compare their sorting times, at least nearly. But after first loop all sorting times decreasing except StoogeSort. I think something optimizating at background but which measure should I consider? First one or the others? And why is this happening?
public static void main(String[] args) {
RandomNumber rn = new RandomNumber();
Scanner sc = new Scanner(System.in);
while(true){
System.out.println("Enter the input size.");
int n = sc.nextInt();
int[] experimentalArray = rn.experimentalArrayGenerator(n);
Stopwatch sw1 = new Stopwatch();
StoogeSort ss = new StoogeSort(experimentalArray.clone());
System.out.println("StoogeSort : " + sw1.elapsedTime() + " µs");
Stopwatch sw2 = new Stopwatch();
RadixSort rs = new RadixSort(experimentalArray.clone());
System.out.println("RadixSort : " + sw2.elapsedTime() + " µs");
Stopwatch sw3 = new Stopwatch();
ShakerSort shs = new ShakerSort(experimentalArray.clone());
System.out.println("ShakerSort : " + sw3.elapsedTime() + " µs");
Stopwatch sw4 = new Stopwatch();
MaximumSubarray ms = new MaximumSubarray();
int a = ms.maxSubArraySum(experimentalArray.clone());
System.out.println("MaximumSubarray : " + sw4.elapsedTime() + " µs");
System.out.println("------------------------------------------------------");
}
}
Output after 4 loop: