CS 2213 Advanced Programming, Fall 2000 Programming Assignment 0


Due In Class, October 3, 2000

In this assignment you will finish the implementation of the Heap Sort that was started in class.


Part 0: Writing and testing the program

Create a directory called prog0 for this assignment.

Copy all of the files from /usr/local/courses/cs2213/fall2000/prog0 into this directory. You should have 4 files: a makefile, a source file (.c), a header file (.h) and an object file (.o).

Insert your printTree function from Lab Assignment 2 in the appropriate place in heapsort.c. You have three additional functions to write.

Create a file called heaptest.c which will contain a main function for testing your program.

Use the makefile to run lint on your program. You should understand all of the messages produced. There should be a message about makeAndTest which is contained in the file heaptester.o. You can ignore this message for now.

Start testing by using the example from class and call insertOneInHeap a few times and check the result by printing out the array.

When you think this is working, you can call makeHeap directly.

Now do the same thing with sortHeapOne and sortHeap.

Use checkSorted to make sure the sort worked correctly.

When you think everything is working correctly, use getRandomArray to create an array of size 10,000 and call makeHeap, sortHeap and checkSorted.

Part 1: Handing in the programs

One of the files you have should be heaptester.o. This contains a function:
void makeAndTest(int size);
which you will use for your final test.

This creates a random array of the given size and calls your makeHeap and sortHeap. It tests to see that these have produced the correct results.

Modify your main program so that it calls this with the sizes 10, 1,000 and 100,000. Use cut and paste to put the results in a file and print it out.

You will be handing in the following:

You can print out the cover sheet with:
lp /usr/local/courses/cs2213/fall2000/cover0.ps

You will consecutively number the pages of your printout and put the page numbers of the various parts on the cover sheet. Be sure to fill in the cover sheet completely.

Staple everything together and hand it in in class on the due date.