goal... The goal of this assignment is to learn about sorting. It also will help you practice modifying someone else's code and document code -- two things that young programmers often have to do in the "real world".
Note: material needed to complete this homework will be discussed in class on Tue Nov 13 and Thu Nov 15.
1. download... the six (6) Java files and one (1) html file that you will need for this assignment. Create a "hw6" directory under your cs1007 account and download all of them into that directory:
2. document...
each method in each class file.
Use the comments at the top of the init()
method in the
Sorter
class as an example.
You MUST specify whether the method is overloading an inherited method or not.
You MUST describe any input arguments (their type, what types of values they
are expected to have and what they are used for in the method).
You MUST describe any return values (if the method is not void).
3. complete...
the SelectionCanvas
class by including the code for
recursive selection sort in the paint()
method.
Use the corresponding paint()
method in the
InsertionCanvas
class as an example.
The class should display the blocks (column-wise) after each pass of the sort,
so that the first column is the same as the original blocks and the rightmost
column contains the sorted blocks.
You MUST use RECURSION for the selection sort.
Hint: you will need to write and use ancillary methods outside of the paint() method.
4. complete...
the BubbleCanvas
class by including the code for
bubble sort in the paint()
method.
Use the corresponding paint()
method in the
InsertionCanvas
class as an example.
The class should display the blocks (column-wise) after each pass of the sort,
so that the first column is the same as the original blocks and the rightmost
column contains the sorted blocks.
5. modify... the classes so that the values in the blocks are 3-letter strings instead of 2-digit numbers.
try...
out my solution: Sorter.html.
You might notice that if your browser repaints after you click on the randomize
button, all the columns in the sort canvases appear in sorted order.
Don't worry about that.
It is an artifact of the fact that I'm drawing the blocks on the fly and not
storing all the columns in the sort canvas classes.
If it really bugs you, you can try to change the behavior...
(but that's not necessary in order to get full credit on the assignment).
6. submit...
As usual, submit your program in two ways: electronically and hard copy.
You will submit all six java files and the html file.
To submit all seven files, make sure that all the files are located in the working
directory where you invoke the submit script.
The submit script should automatically pick up all the files (and should tell you
so when asking for you to confirm the submission).
The hardcopy must contain 7 sections in the following order:
Homeworks must be submitted electronically by 12 NOON on Wed Nov 21; otherwise they will be counted as late (unless you have an approved extension).