//File: NumberList.java import iostuff.*; import java.io.*; public class NumberList { public static int [] inputList () { System.out.print ("How many items in your list? "); int n=Keyboard.readInt(); System.out.println(n); //allocate n memory locations for array x int [] x = new int [n]; //fill the array x with values from the user for (int k=0; k=0 && list[j]>currentItem) //stops when finds //a smaller item { //looking for place to put list[i] //so moving elements to the right //to make room list[j+1] = list[j]; //jth item --> j+1 slot j--; } //list[i] goes into the j+1 slot immediately to //right of smaller item list[j+1] = currentItem; } } static void swap (int [] list, int i, int j) { int temp = list[i]; list[i] = list[j]; list[j] = temp; } static void selectionSort (int [] list) { for (int k=0; k a[i] ) { int temp; // exchange the out-of-order elements temp = a[i-g]; a[i-g] = a[i]; a[i] = temp; inorder = false; } } } } public static void ShellSort(int [] a ) { // This method uses sortComb to progressively bring // array a into order by sortsusing finer and finer combs // ending with an ordinary bubble sort. int gap = a.length/2; while ( gap > 0 ) { sortComb(a, gap); gap /= 2; } } public static int readIn (String fileName, int [] list) { int count=0; try { //The FileReader converts byte stream to char stream FileReader fr = new FileReader (fileName); //The BufferedReader enables efficient buffering of stream BufferedReader inFile = new BufferedReader (fr); String line = inFile.readLine(); //readLine() is in //BufferedReader class while (line != null) //null is the pointer //that points nowhere -- //when no more lines in //file, line = null. { list [count] = Integer.parseInt (line); count++; line = inFile.readLine(); } inFile.close(); //not invoked if throws exception } catch (FileNotFoundException e) { System.out.println ( "The file " + fileName + " was not found."); } catch (IOException e) { } return count; } }