/** Driver.java -- Let's test some sorting methods, such as selection and * insertion sort. */ import java.io.*; public class Tester { public static void main(String [] args) throws IOException { int a, b, c, d, e; long maxSwap = 0, maxSelection = 0, maxInsertion = 0, maxBubble = 0; int swapCase=0, selectionCase=0, insertionCase=0, bubbleCase=0; for (a = 1; a <= 5; ++a) for (b = 1; b <= 5; ++b) for (c = 1; c <= 5; ++c) for (d = 1; d <= 5; ++d) for (e = 1; e <= 5; ++e) { if(a==b||a==c||a==d||a==e||b==c||b==d||b==e||c==d||c==e||d==e) continue; int [] ar = new int[5]; ar[0] = a; ar[1] = b; ar[2] = c; ar[3] = d; ar[4] = e; Array array = new Array(ar); long swap = array.getSwapOps(); array = new Array(ar); long selection = array.getSelectionOps(); array = new Array(ar); long insertion = array.getInsertionOps(); array = new Array(ar); long bubble = array.getBubbleOps(); if (swap > maxSwap) { maxSwap = swap; swapCase = 10000*a + 1000*b + 100*c + 10*d + e; } if (selection > maxSelection) { maxSelection = selection; selectionCase = 10000*a + 1000*b + 100*c + 10*d + e; } if (insertion > maxInsertion) { maxInsertion = insertion; insertionCase = 10000*a + 1000*b + 100*c + 10*d + e; } if (bubble > maxBubble) { maxBubble = bubble; bubbleCase = 10000*a + 1000*b + 100*c + 10*d + e; } } System.out.println("swap " + swapCase + " " + maxSwap); System.out.println("selection " + selectionCase + " " + maxSelection); System.out.println("insertion " + insertionCase + " " + maxInsertion); System.out.println("bubble " + bubbleCase + " " + maxBubble); } }