Homework 5 - Heaps and Heap Sort by yurtgc548


									                  Homework 5 - Heaps and Heap Sort
               Algorithms I - CSCI 700 - Fall 2010 - Prof. Rosenberg

                              Due October 14 at 6:30pm

   In this assignment, you will write a Heap class and use it to implement HeapSort.
   The Heap class must be defined in two files heap.cc and heap.h or in heap.java.
   The Heap class must support, at least, the following functions.

void insert(const int a)
int maximum()
int popMaximum()

    As in Assignment 3, your program will read input from an input file which contains
one integer per line, and write sorted output to an output file which contains the same
integers in sorted order. You may use the fileio.h and fileio.cc or fileio.java code
that you wrote for Assignment 3 in this assignment.
    Also like Assignment 3, your program should write the number of comparisons made
during the sorting function to standard output.

   • A heap.cc and heap.h or heap.java file which implement the Heap data structure.

   • A heapsort.cc or heapsort.java file which uses the Heap data structure to implement
     the heapsort algorithm

   • A fileio.cc fileio.h or fileio.java which implement the reading and writing functions
     that each of the sorting program will use.

   • A plain text README file describing the heap data structure and heapsort func-
     tions including the theoretical and actual number of comparisons required for each

   • Run each program on each of the five sample input files. In your README file,
     report the number of data points, n, in each file, as well as the number of comparisons
     heapsort uses to sort them.

   The program must compile using the following command on a CS network computer.

g++ heapsort.cc fileio.cc heap.cc -o heapsort

javac heapsort.java heap.java filio.java

  The program must run using the following command on a CS network computer.

./heapsort input_filename output_filename

java heapsort input_filename output_filename


  • 15 points - Compilation Each file must compile without error or warning into an
    executable as described above.

  • 15 points - Execution The executable must run without error or warning on valid
    input using the command line parameters described above.

  • 15 points - README Does your README documentation completely and ac-
    curately describe the heap data structure and heapsort algorithm? Does it include
    theoretical and actual numbers of comparisons on the 5 sample input files?

  • 10 points - Within Code Documentation Is the code documented for obvious
    understanding of the use, preconditions, and postconditions of each function?

  • 10 points - Style Are functions and variables given self-explanatory names? Are
    functions used to aid intelligibility of the code? Are functions used to reduce repeated
    blocks of code? Is indentation, spacing, use of parentheses, use of braces consistent
    and sensible?

  • 20 points - Correctness Are the insertion, deletion, get and pop functions imple-
    mented correctly?

  • 15 points - Automated Testing There will be five automated tests. Does the
    executable produce correct output for all five files?


To top