CS233V C++ Programming

Assignment #10A

Programming

A Priority Queue is a simple data structure defined basically by two functions: void insert(int x) that inserts x into the structure and int remove() that removes and returns the maximum value currently in the structure.

Define and implement class IntegerPQ by derivation using class Array. In addition to void insert(int x ) and int remove(),implement a constructor IntegerPQ(int n),bool isEmpty(), and the assignment operator =. Other functionality of the Array class must not be allowed for IntegerPQ objects. You can assume that the Array class storage array ptr[] and size are protected. If you wish you can use the public member functions of Array instead.

Include a driver program that tests the full functionality.

Hints: This has little to do with the other queue we talked about. It is not circular, and is relatively easy to implement. Note that when you remove the maximum value you must somehow deal with the vacant position.