================================================================================ README Author: Ed Ropple (ed@edropple.com) Date: February 5, 2009 FILES IN SUBMISSION CnetCheckSortMain.java: solution for Problem 19.e CnetCreateTrisortMain.java: solution for Problem 19.b CnetCreateMexsortMain.java: solution for Problem 19.c CnetGraToLinMain.java: solution for Problem 19.a.ii CnetLinToGraMain.java: solution for Problem 19.a.i CnetShowRunMain.java: solution for Problem 19.d ComparatorPair.java: helper library Functions.java: helper library Makefile: makefile for this assignment; type 'make' to build all. (Will generate Javadoc) HOW TO COMPILE At the command line in the program root directory (where the README file is) enter the following command: make This should, on a system where GNU make is aliased to make, correctly build all Java files and create the Javadocs. Will not work correctly with Solaris or BSD make. Please note that due to the limitations of make (and not being able to easily integrate ant with the build), all Java classes are in the default classpath. As such, the Javadocs may look a little weird, but all the information is in the respective classes. The Javadocs are stored in the "doc" subdirectory once make has been invoked. HOW TO RUN APPLICATIONS Running the applications is a little skiffy because I didn't think that packing shell scripts with the code just to have "./cnet-lin-to-gra" was necessary, as as far as I can tell we're operating under the same rules as COS 226 where this method outlined below was accepted every time and nothing to the contrary has been stated. -To run cnet-lin-to-gra (Problem 19.a.i): java CnetLinToGraMain -To run cnet-gra-to-lin (Problem 19.a.ii): java CnetGraToLinMain -To run cnet-create-trisort (Problem 19.b): java CnetCreateTrisortMain -To run cnet-create-mexsort (Problem 19.c): java CnetCreateMexsortMain -To run cnet-show-run (Problem 19.d): java CnetShowRunMain -To run cnet-check-sort (Problem 19.e): java CnetCheckSortMain HOW TO TEST APPLICATIONS Included are a set of test files. The mechanism for testing them is going to be a little bit rickety, but will do what's necessary. Please note that the programs are very verbose and output a lot of helper text; this can be safely ignored in favor of the output listed, which will be the last set of lines emitted by the Java programs. PROBLEM 19.a.i TO TEST: cat cnet-lin-to-gra.1.test | java CnetLinToGraMain OUTPUT: The output will match the contents of cnet-gra-to-lin.1.test, before its terminating 'X' to cause the program to finish input. It has not been duplicated here because it's really long and is also the output of Homework 1's Problem 4. (The test input is the same as the test input given in the problem set for Problem 19.a.i; the rationale behind this is that the code is either going to succeed completely or fail completely. No test is provided for failure because while I included bulletproofing for bad values, nothing relevant will be returned, just a print to stderr and exit or a thrown exception in a couple of cases.) PROBLEM 19.a.ii TO TEST: cat cnet-gra-to-lin.1.test | java CnetGraToLinMain OUTPUT: 0 8 1 9 0 4 1 5 2 6 3 7 4 8 5 9 0 2 1 3 4 6 5 7 2 8 3 9 2 4 3 5 6 8 7 9 0 1 2 3 4 5 6 7 8 9 1 8 1 4 3 6 5 8 1 2 3 4 5 6 7 8 (Obviously the output will not be indented; they've been indented here in order to keep things in proper format.) The output will match the values in cnet-lin-to-gra.1.test, with the differences that it will be output in the specified canonical form; it will also match the value in the problem set for Problem 19.a.i. As with Problem 19.a.i, no failing tests are provided because failing tests will only raise an exception and provide no useful output (there's no "constructive failure" for this, like with 19.a.i). PROBLEM 19.b TO TEST: cat cnet-create-trisort.1.test | java CnetCreateTrisortMain OUTPUT: 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 0 1 1 2 2 3 3 4 4 5 5 6 6 7 0 1 1 2 2 3 3 4 4 5 5 6 0 1 1 2 2 3 3 4 4 5 0 1 1 2 2 3 3 4 0 1 1 2 2 3 0 1 1 2 0 1 (Again, the output will not be indented; they've been indented here in order to keep things in proper format.) TO TEST: cat cnet-create-trisort.2.test | java CnetCreateTrisortMain OUTPUT: 0 1 1 2 2 3 0 1 1 2 0 1 (Again, the output will not be indented; they've been indented here in order to keep things in proper format.) PROBLEM 19.c TO TEST: cat cnet-create-mexsort.1.test | java CnetCreateMexsortMain OUTPUT: 0 2 1 3 0 1 2 3 1 2 (Again, the output will not be indented; they've been indented here in order to keep things in proper format.) This is the correct output for a merge-exchange sort on four inputs; the values for all inputs 2-10 have been verified through cnet-check-sort for correctness. This one is just a convenience example. PROBLEM 19.d TO TEST: cat cnet-show-run.1.test | java CnetShowRunMain OUTPUT: 0 1 2 3 4 5 6 7 8 9 ..|..|..|..|..|..|..|..|..|..| 99 88 77 66 55 44 33 22 11 0 ..o--o..|..|..|..|..|..|..|..| 88 99 77 66 55 44 33 22 11 0 ..|..|..o--o..|..|..|..|..|..| 88 99 66 77 55 44 33 22 11 0 ..|..|..|..|..o--o..|..|..|..| 88 99 66 77 44 55 33 22 11 0 ..|..|..|..|..|..|..o--o..|..| 88 99 66 77 44 55 22 33 11 0 ..|..|..|..|..|..|..|..|..o--o 88 99 66 77 44 55 22 33 0 11 (Again, the output will not be indented; they've been indented here in order to keep things in proper format.) This is an example of a non-sorting comparator network. TO TEST: cat cnet-show-run.2.test | java CnetShowRunMain OUTPUT: 0 1 2 3 4 5 6 7 8 9 ..|..|..|..|..|..|..|..|..|..| 33 22 11 0 ..o--o..|..|..|..|..|..|..|..| 22 33 11 0 ..|..o--o..|..|..|..|..|..|..| 22 11 33 0 ..|..|..o--o..|..|..|..|..|..| 22 11 0 33 ..o--o..|..|..|..|..|..|..|..| 11 22 0 33 ..|..o--o..|..|..|..|..|..|..| 11 0 22 33 ..o--o..|..|..|..|..|..|..|..| 0 11 22 33 (Again, the output will not be indented; they've been indented here in order to keep things in proper format.) This is actually data pulled from cnet-create-trisort with 4 elements maximum; I did not use a full-size 10-element one because I don't think that anybody wants to be spammed with 100+ lines of test output. In keeping with the others, bad input is not tested as it just generates exceptions or comments to stderr and terminates. PROBLEM 19.e TO TEST: cat cnet-check-sort.1.test | java CnetCheckSortMain OUTPUT: 0 (Again, the output will not be indented; they've been indented here in order to keep things in proper format.) This tests the comparator network "0 1 2 3 4 5 6 7", which is obviously not a valid sorting network, so it returns 0. TO TEST: cat cnet-check-sort.2.test | java CnetCheckSortMain OUTPUT: 1 (Again, the output will not be indented; they've been indented here in order to keep things in proper format.) This tests the comparator network "0 1 1 2 2 3 0 1 1 2 0 1", which is a triangle network for 4 elements (same one used in cnet-show-run.2.test); this is a known working sort (as with the other trisorts). ================================================================================