Question: #include PQueue.h #include using namespace std; #include int main() { PQueue pq(10); for(int i = 0; i PQueue This priority queue is implemented using a

 #include "PQueue.h" #include using namespace std; #include int main() { PQueue

#include "PQueue.h" #include using namespace std; #include int main() { PQueue pq(10); for(int i = 0; i  

PQueue This priority queue is implemented using a heap heap: int length: int -capacity: int reheapup(top: int, bottom: int): void reheapdown(top: int, bottom:int): void +PQueue(c: int): -PQueue(0 +enqueue(i: int): int +dequeue(: int&): int +clear): void +isFull(): bool +isEmpty(): bool Accessors should be const Use the above UML diagram to write a class implementing a priority queue implemented as a heap The class has the following attributes: heap a pointer that holds the memory address for a dynacyacated array of integers used to store the heap length the current "length" of the queue. Also serves to indicate the bottom of the heap. Could have named this attribute "bottom capacity the number of elements of the dynamically allocated array The class has the following private methods e reheapup used to restore the heap after a value has been queued reheapdown used to restore the heap after a value has been dequeued. The class has the following public methods: constructor accepts an integer argument and intializes the class. destructor takes care of the dynamically allocated array enqueue adds it's argument to the heap. Returns O if successful, -1 otherwise dequeue retrieves the highest value from the top of the heap through the reference parameter. Returns 0 if successful,-1 otherwise clear resets the length to 0 isFull - returns true if the queue is full, false otherwise .isEnpty-returns true if the queue is empty, false otherwise PQueue This priority queue is implemented using a heap heap: int length: int -capacity: int reheapup(top: int, bottom: int): void reheapdown(top: int, bottom:int): void +PQueue(c: int): -PQueue(0 +enqueue(i: int): int +dequeue(: int&): int +clear): void +isFull(): bool +isEmpty(): bool Accessors should be const Use the above UML diagram to write a class implementing a priority queue implemented as a heap The class has the following attributes: heap a pointer that holds the memory address for a dynacyacated array of integers used to store the heap length the current "length" of the queue. Also serves to indicate the bottom of the heap. Could have named this attribute "bottom capacity the number of elements of the dynamically allocated array The class has the following private methods e reheapup used to restore the heap after a value has been queued reheapdown used to restore the heap after a value has been dequeued. The class has the following public methods: constructor accepts an integer argument and intializes the class. destructor takes care of the dynamically allocated array enqueue adds it's argument to the heap. Returns O if successful, -1 otherwise dequeue retrieves the highest value from the top of the heap through the reference parameter. Returns 0 if successful,-1 otherwise clear resets the length to 0 isFull - returns true if the queue is full, false otherwise .isEnpty-returns true if the queue is empty, false otherwise

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!