Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Use the above UML diagram to write a class implementing a priority queue implemented as a heap. The class has the following attributes: heap

C++ image text in transcribed
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 dynamically allocated 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 initializes the class. destructor - takes care of the dynamically allocated array enqueue - adds it's argument to the heap. Returns 0 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 isEmpty - returns true if the queue is empty, false otherwise. #include "PQueue.h" #include using namespace std: #include int main() { PQueue pq(10): for (int i = 0: i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions