// Source code example for "A Practical Introduction // to Data Structures and Algorithm Analysis" // by Clifford A. Shaffer, Prentice Hall, 1998. // Copyright 1998 by Clifford A. Shaffer import java.io.*; // Driver to test the permute and largest functions class Permutemain { // A version of "largest" that uses Elem's instead of ints. // The book version (largest.txt) uses int's since at that // point in the text, the Elem class and the key method had // not been defined. static int largestE(Elem[] array) { // Find largest value int currLargest = 0; // Store largest value for (int i=0; i currLargest) // if this is largest currLargest = array[i].key(); // remember it return currLargest; // Return largest value } // Here is the version that appears in the book. // It should be nearly identical to largestE. static int largest(int[] array) { // Find largest value int currLargest = 0; // Store largest value for (int i=0; i currLargest) // if this is largest currLargest = array[i]; // remember it return currLargest; // Return largest value } // Main function for permute/largest test public static void main(String args[]) throws IOException { Assert.notFalse(args.length == 1, "Usage: Permutemain "); int size = Integer.parseInt(args[0]); // Get size Elem[] A = new Elem[size]; // Create an array for (int i=0; i