Menu

[Solved]Write C Program Using Following Template Class Class Heapqueue Private Int Heap Int Size B Q37294418

Write a c++ program using the following template of a class.

class HeapQueue
{
private:
   int *heap;
   int size, bottom;
public:
   HeapQueue(int s);
   ~HeapQueue();
   void enqueue(int i);
   void dequeue();
   int top();
   void ReHeapUp();
   void ReHeapDown();
};

With the explanations for each function:
ATTRIBUTES * heap- a pointer that holds a dynamically allocated array of integers. . size -stores the size of the array. bott

ATTRIBUTES * heap- a pointer that holds a dynamically allocated array of integers. . size -stores the size of the array. bottom – keeps track of the bottom of the heap. constructor-accepts an integer as it’s only argument and dynamically allocates an array with that many elements, stores the argument in size, and initializes bottom to -1. Address of the new array is stored in heap. * destructor – deallocates the array enqueue – if there’s enough free space in the heap, adds it’s argument to the heap. . dequeue – if the heap isn’t empty, removes the top of the heap from the heap. top-returns a copy of the value on the top of the heap, doesn’t change the heap in any way. Returns -1 if the heap is empty. . ReHeapUp – called by enqueue to rebuild the heap. . ReHeapDown – called by dequeue to rebuild the heap. Show transcribed image text ATTRIBUTES * heap- a pointer that holds a dynamically allocated array of integers. . size -stores the size of the array. bottom – keeps track of the bottom of the heap. constructor-accepts an integer as it’s only argument and dynamically allocates an array with that many elements, stores the argument in size, and initializes bottom to -1. Address of the new array is stored in heap. * destructor – deallocates the array enqueue – if there’s enough free space in the heap, adds it’s argument to the heap. . dequeue – if the heap isn’t empty, removes the top of the heap from the heap. top-returns a copy of the value on the top of the heap, doesn’t change the heap in any way. Returns -1 if the heap is empty. . ReHeapUp – called by enqueue to rebuild the heap. . ReHeapDown – called by dequeue to rebuild the heap.

Expert Answer


Answer to Write a c++ program using the following template of a class. class HeapQueue { private: int *heap; int size, bottom; pub… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *