//Array sorting algorithms //Author: Patrick Campeau //Version 0.7 //To add: //-mergeSort //-quickSort //-comments for all functions import java.util.Arrays; public class Sorting { public static void main(String[] args) { int[] data = new int[48000]; for (int i=0; i0 && a[j] < a[j-1]) { swap(a, j, j-1); j--; } } } public static void bubbleSort(int[] a) { for (int i=0; i a[j+1]) { swap(a, j, j+1); } } } } public static void selectionSort(int[] a) { for (int i=0; i a[i+1]) { return false; } } return true; } public static void shuffle(int[] a) //Fisher-Yates shuffle algorithm { for (int i=a.length-1; i>=0; i--) { int j = (int)(Math.random() * (i+1)); //0 to i swap(a, j, i); } } public static void naiveShuffle(int[] a) //bad algorithm because not all possible outcomes have the same odds of occurring { for (int i=0; i