CSC 241- Assignment 3 (Due August 5th 1996)
Your main task here is to develop the merge sort algorithm, but, we would
like a user interface that graphically demonstrates how it works.
- Add a sort method to intList. It will be helpful to
already have done lab4 before this assignment. In that lab
you added a size field to intList that will be
used here. As the name indicates this method sorts the list of
integers. However, it doesn't do this on its own. When the
sort
method is invoked you must then invoke a recursive merge sort method
that is private and takes the head of the list as and the size of the
list as parameters. This
recursive sort method will return a new head which is the head of
the list after the sorting is complete.
- Test the sort method by writing a test program. This test program
must append 100 randomly generated integer numbers in the rage of
10 to 300 to the list, invoke
the dump method, invoke the sort method, and again
invoke the dump method. You will need to import the
class java.lang.Math. This class has a random ()
method which you can use to generate random numbers between 0 and 1.
To demonstrate the use of random (), I wrote test3.java .
- Develop a Sort Applet which has been inspired by
Sort Applet Demo
made available at javasoft. Notice that the Applet that
you will develop won't have the multi-threading requirements that the
demo from javasoft had. It is still a neat little applet!
You have the choice of extending intList further to give it
drawing capabilities or letting the applet draw the lines.
It may be easier to let intList
hold integer values and let the applet draw the lines. The idea
is simple, you start with a default list of values, say 20 randomly
chosen integers. Draw lines based on those values. Also, show those
values at the bottom of the screen (I used the dump method
in intList). Each time the user clicks on the
Sort List, your applet sorts the list and redraws the lines,
also dumping the sorted list at the bottom. Each time user clicks on
New List, a new set of values are generated that you
again draw lines for and dump at the bottom. The Max Count
is made changable, but you can't allow too many lines. Checkout
Tank Applet2 written by my independent study student David Fleming for some hints
on user interfaces.