ICSG707 -- Programming Practices

Lab1 -- Working with Heaps

Description

In this project you will be implementing the HEAP Abstract Data Type that we discussed in class. Your heap should use integers as the data items, and should store the data with the property that a parent node always contains larger data than its children.

I will test your HEAP ADT with a test program of mine so your heap will have to conform to the following header file specifications:

Structure Description

You will have to define the specific data that you want inside the heap. The important thing is that the heap structure be named a_heap.

Function Description

init_heap

This function initializes the heap, getting it ready to be used. This includes dynamically allocating space for the heap array, giving it enough room to allow for max_heap_size elements to be added to the heap.

destroy_heap

This function should free the dynamically allocating space used by a heap.

add_element

This function will insert the element argument into the provided heap.

remove_element

This function will remove and return the largest element from the heap.

print_heap

This function should print out the contents of the heap array on a single line separated by spaces. A new line should be printed after the last element.

Test Driver Program

You must implement a test driver main program that will test your heap to make sure that it is working correctly. This driver program will be graded, so you should make sure that it contains code that will completely tests all the functions of the heap.

I will be testing your heap ADT using my own test program. To help you make sure that your code will compile with my test program, I have created an object files that you can link in with your heap files to make sure that your program will compile with mine. In addition I have compiled that object file with my heap code to create an executable. Both of these files are in the pub directory of my grader account at:

The files that are available are:

Code Deliverables

You must use separate files to contain the code for you heap ADT and your test driver program. Specifically, you must call the file that contains the code for the heap ADT heap.c and heap.h and the file containing your driver program test.c.

README

You must submit a file named README with your project. This file should contain information that I should know about your program. This must include how to compile and run your test program. It should also contain a list of all the files submitted describing what the files contain, and why they were submitted. In addition, you include any notes you think would be useful while I grade the assignment.

Grading

This project will be graded out of 50 points

For "program design, style, and documentation" I am looking for programs that have broken the tasks up into "meaningful chunks" of manageable size (try to keep all functions to less than one page, ~25 lines of code). As for style, I am looking for code that is neat, clear and consistent. I will also look for good block comments for all program files and functions you submit. Plus comments for sections of the code whose function is not obvious (good variable names will make these comments less important).

Project Submitting

When your program is correct, submit it for grading with the following command from any Dept. of computer science Sun UltraSparc machine (the submit command may not work on the Indy workstations). Where heap.c and heap.h are your code and header files for the implementation of your heap ADT and test.c is the test driver program that you wrote.

Submit your "Makefile" if you used one to compile your code.

Do not submit any executable or object files.

Feel free to submit any other code, header or data files that you used in the development or testing of your program (as long as you submit the files specified). If you do submit any extra files, make sure that you document their use in the README file.

For information on the submit command check out: