import java.util.*; import java.io.*; public class QueueSort> { private ArrayQueue> Q; public static final int CAPACITY = 10; // default queue capacity private int n; private boolean trace; public QueueSort(){this(CAPACITY);} public QueueSort(int capacity){ n = capacity; Q = new ArrayQueue>(n); } private ArrayQueue merge(ArrayQueue q1,ArrayQueue q2) throws ArrayQueueException { return null; } // // IMPLEMENT ME // Take two sorted queues and merge them to produce a third // sorted queue // public void sort(){} // // IMPLEMENT ME // given a queue Q of queues // (1) if Q is of size 1 deliver the first queue in Q // (2) if Q is of size 2 or more // - get the first and second queues off Q // - merge these two queues to create a third queue // - add the third queue to the queue // - go back to (1) // public void add(E element){} // // IMPLEMENT ME // create an ArrayQueue that contains the element // enqueue it onto Q // public String toString(){return Q.toString();} public void trace(){trace = !trace;} public static void main(String[] args) throws IOException { Scanner sc = new Scanner(new File(args[0])); ArrayList data = new ArrayList(); while (sc.hasNext()) data.add(sc.next()); int n = data.size(); QueueSort QS = new QueueSort(n); for (String s : data) QS.add(s); if (args.length > 1) QS.trace(); QS.sort(); System.out.println(QS); } }