//This program is implementation of the sorting algorithm //known as "selection sort". As explained in the class, //it selects the smallest element and swaps it with the //first element of the array A. It then selects the smallest //number from A[1] onwards and swaps it with A[1], and so on ... //It first reads the size of the array from command line //Then it fills the array with randomly generated numbers in the range //0 to 999. It prints the array. Then it sorts the array and prints the //sorted array. import java.util.Random; class selection_sort { public static int index_of_smallest_value(int[] B,int start, int end) { int index_of_smallest = start; int index = start+1; for(;index<=end; index=index+1) { if(B[index_of_smallest] > B[index]) index_of_smallest = index; } return index_of_smallest; } public static void swap_values_at(int[] B, int i, int j) { int temp = B[i]; B[i] = B[j]; B[j] = temp; } public static void build_array_randomly(int[] B, int range) { Random rand = new Random(); int value; for(int i = 0; i