CIS 11: Data Structures & Algorithms
Project J
Implement the Priority Queue class, using a heap to store the items, as described in Section 11.1 of the text.
- Links to files in the project:
- pqueue.h: the header file for this version of the PriorityQueue class.
- pqueue.cpp: the implementation file for the new PriorityQueue class. This contains just stubs and your job is to finish it. It is the only file you will submit.
- pqtest.cpp: A simple interactive test program.
- pqexam.cpp: A non-interactive test program that will be used to grade the correctness of your PriorityQueue class.
- The PriorityQueue class for this project will use a heap that is stored in an array. The component type of the array is called OneItemInfo, and is defined as part of the PriorityQueue class in pqueue.h. To gain more experience with private (utility or helper) member functions, write and use all of those that are listed in pqueue.h. The precondition/postcondition contracts for these functions are given in the stub version of pqueue.cpp.
- This version of the priority queue does not use dynamic memory. Consider what this means with respect to the need for a copy constructor, an assignment operator, and a destructor.
- For easier debugging, carry out this project in two parts:
- First include everything except the public get_front() member function and the private functions that are needed for it: is_leaf(), big_child_index(), and big_child_priority(). While debugging this part, add a new option to the interactive test program. The new option makes this call to print the current state of the tree of the test PriorityQueue:
test.print_tree("STATE OF THE TREE: ");
// Note that print_tree() is a public member function
// that was written for you. It should be removed
// before submitting your final work.
- Complete the project by implementing the get_front() member function and its associated private functions.
When you're satisfied with the implementation, submit your work via the CATE form for Project J.
Legend: method/function keyword literal
2007/04/17