Briefly, however, you can try out ISCAL with one of the example files in /cs/cs60/as/a13/ . First, be sure the directory
/cs/cs60/binis in your path environment variable. (This may require editing your .cshrc file.)
Copy any (or all) of the files from /cs/cs60/as/a13 to your own cs60/a13 directory. Then you can run one of them, say fac.isc , by typing
isc fac.iscIf /cs/cs60/bin is not in your path, you can type
/cs/cs60/bin/isc fac.isc
The program accepts integers entered one at a time to the standard input (the keyboard) and immediately prints out the factorial of each one. If you push the limits of the program you will discover some odd behavior (negative numbers or zero for inputs that overflow the 32-bit ISC limit).
In addition to fac.isc , there are several other ISCAL examples to work from. To demonstrate how to implement recursion, there is a file named
rfac.iscthat does the same thing as fac.isc, but does so recursively. It demonstrates how to build up a stack that preserves the data needed for each recursive call. This code can't be copied wholesale for use in quicksort, but it does give the idea.
There is also a file named
part.iscin the directory /cs/cs60/as/a13 that implements all of the input/output routines you need, as well as the partitioning half of the quicksort algorithm. This file is a good starting point for creating your qsort.isc file.
Your quicksort can be built by modifying subroutine 'part' in part.isc. After partitioning the array, quicksort makes two recursive calls to itself. What you have to do is add the code for making these recursive calls.
Note that quicksort does not need to return a value; rather it modifies its argument array in place. It is recommended that the array be represented by pointers to the bottom and top locations in the array. (This is the way that 'part' is set up.) The subroutine 'part' also returns the pivot element as a value. This is not needed for quicksort.
Quicksort is described in detail in the text (and there may be a couple of class sildes about it), but there is also a java-code version at
/cs/cs60/as/a13/quicksort.javaAfter compiling it (it will compile but complain about the use of deprecated library calls), you will need to redirect a file of numbers to it when running, e.g.,
% random 10 > mynumbers % java quicksort < mynumbers/cs/cs60/bin/random is a program that outputs a list of randomly generated integers -- however many are specified in its argument.
Ultimately, however, you need not run the java quicksort; it is there simply as a guide to the algorithm.
Submit your ISCAL file for the complete program in the usual way, i.e., with
% cs60submit qsort.iscYou will be asked to input the assignment number (13). This assignment will be worth up to 50 points, but is graded "out of" 0 points, in that it's entirely optional.