Data Structures Project 3

Due: Monday, Nov 20, 2000, 11am. 100 points.

In this project, you will implement the Priority Queue interface using a heap. Your constructor for making a Priority Queue should be able to take a Comparator object as an argument, and it should use Comparators to do all comparisons (your default Comparator should be able to perform comparisons of Integer objects). Your heap data structure should be built using the binary tree interface, and this interface should be implemented using an array. Note: you may augment your binary tree class to add a method for identifying the last node. In addition, if you run out of space for nodes, double the length of array. If the number of elements in the priority queue becomes less than half the length of the array, copy elements into another array half as long.

The assignment, then, is to build a class that implements each method in the Priority Queue ADT. Since the Priority Queue is implemented using a heap, which in turn is implemented using a simple binary tree, this assignment involves you producting other classes as well:

In addition, your HeapPriorityQueue implementation should have a constructor:
      HeapPriorityQueue(Sequence S),
which takes a sequence of Object Combinators (see ComposedObj.java). (Use the implementation of Sequence from project 2. If you don't quite trust your implementation, you may use an array of combinators instead of a sequence as the input parameter.) The construction must be bottom up. You may assume unique keys.

In addition to the priority Queue, write a HeapSorter class which provides the following method

Your main method must read a list of integers from a file, input.txt , then make combinator objects with the integers as the keys and Dummy.NULL_ELEMENT as the elements. It then uses HeapSorter.sortBound() method to sort the objects. Finally, it writes the the sorted sequence (or array) back into the file output.txt.

The following files are provided to help guide your software development: