CS 11 -- Lab 6

Here, we implement a few of our sorting algorithms.


Your assignment

Our goal is to test our sorting methods, ensuring that they sort correctly. Specifically, we want the program to perform the following steps:

  1. Create an array of random integer values between 0 and some maximum possible value. The user should be prompted to determine the length of the array and the maximum value.
  2. Print the first 20 values of the array.
  3. For each sorting algorithm to be tested:
    1. Create a copy of the random array of integers.
    2. Sort the array using the desired algorithm.
    3. Print the first 20 values of the sorted array.
    4. Test all elements of the array to determine if they are, in fact, in order, and print the result of that test.

In order to perform these tasks, you should write and use the methods described below. Remember that as you write new methods, you should compile and test them before trying to write the next method!

Hint: Not only should you test your program with every new method you write, but you should also test your program first with simple cases, and then with more complex ones. That is, try creating and sorting arrays with only 1 element. After fixing any bugs that arise, try 2 elements, then 3. It is likely that you will find more than 90% of your bugs before trying sizes larger than 3.


Submit your work

Submit, as lab-6, your SortingTest.java file using the cs11-submit command.


Note that this is a double lab, and you will have two weeks for it. This assignment is due at 11:59 pm, Thursday, 2005-Nov-12

Scott F. Kaplan
Last modified: Fri Nov 5 11:17:29 EST 2004