Using a heap, implement the priority queue class. The classshould have a static constant member variable, CAPACITY, which isthe maximum size of the heap and an array, data, that contains theheap with the entries.
Header:
class priorityQueue
{
private:
int size;
int *data;
public:
static const int CAPACITY = 50;
priorityQueue();//constructor
~priorityQueue();//destructor
int getParent(int index);
int getLeftChild(int index);
int getRightChild(int index);
void swap(int &, int &);
void insert(int item); //enqueue – heap_insert
void printArray(int []);
void heapify(int index);
//remove and return the smallest item currently in the priorityqueue
int extractMin();//dequeue
bool empty() const;
int min() const; //return the smallest item
};
Driver:
int main()
{
priorityQueue myqueue;
if(myqueue.empty())
cout <<“My priority Queue isemptyn” <<endl;
myqueue.insert(59);
myqueue.insert(41);
myqueue.insert(25);
myqueue.insert(12);
myqueue.insert(91);
myqueue.min();
myqueue.extractMin();
myqueue.insert(34);
myqueue.insert(63);
myqueue.extractMin();
myqueue.insert(75);
myqueue.insert(85);
myqueue.extractMin();