Programming Assignment 1

Background

The goals of this initial programming assignment are:
 
  • to refresh your basic Java programming skills;
  • to review some of the sorting routines you studied in CS216 - Data Structures;
  • and most importantly, to impress on you the importance of algorithm choice and design.

  •  

     

    You will accomplish these goals by writing a Java program which sorts different-sized files using selectionsort, mergesort, and quicksort and counts the number of operations in each case. By analyzing the results, you will be able to see clearly how well the three methods perform.

    Assignment

    In the course directory /Courses/CS311/ProgramAssign1, there are three files called SelectionSort.java, MergeSort.java, and QuickSort.java. These files are Java classes for sorting an array of integers in increasing order using the named sorting methods. They contain minimal comments; for more details, see your CS216 textbook. Also in this course directory are two sets of integer files. The five files randomN contain N random integers, and the five files orderN contain the integers from 1 to N already sorted in increasing order.
    1. Write a Java driver program which uses the given sort classes to sort a file of integers and count the number of comparisons. Your program should allow a user to specify which sort method to use. To count the number of comparisons, you will have to modify the given sort classes in an appropriate manner. Run your program on each of the ten integer files.

    2.  
    3. Using the comparison counts, perform calculations which illustrate the orders of the methods on the two types of files (random and ordered). Summarize your results in a table like the folllowing:
    4.                         | Random File | Ordered File
                --------------|-------------|--------------
                Selectionsort |             |
                --------------|-------------|--------------
                    Mergesort |             |
                --------------|-------------|--------------
                    Quicksort |             |
                --------------|-------------|--------------
       
    5. Describe the advantages and disadvantages of each algorithm in each case. Justify and explain your conclusions.

    Ground Rules

    See the rules for programming assignments on the main course Webpage. You may work individually or in teams of two or three people.

    Submission

    You or your entire team (as a group) will meet with me to demonstrate your program and discuss your results. All necessary work should be completed and organized in a presentable form before we meet. At the meeting, you should be prepared to discuss what you did. We will not be able to cover every detail during a particular meeting, and different meetings will proceed differently. Thus, you need to be ready to talk about anything that may come up during your meeting.

    Due Date and Time

    There are two deadlines to observe. Since I will not take walk-ins, you must schedule your meeting by the end of class on Monday, September 3. The deadline for the meeting itself is noon on Wednesday, September 5. These deadlines are firm. Late work is not accepted, but early birds are always welcome!