Question: Write in c++ only Header file Heap.h //-------------------------------------------------------------------- // // Laboratory 12 Heap.h // // Class declaration for the array implementation of the Heap ADataType

Write in c++ only

Write in c++ only Header file Heap.h //-------------------------------------------------------------------- // // Laboratory 12

Heap.h // // Class declaration for the array implementation of the HeapADataType // //-------------------------------------------------------------------- #ifndef HEAP_H #define HEAP_H #include #include using namespace std;

Header file Heap.h

//-------------------------------------------------------------------- // // Laboratory 12 Heap.h // // Class declaration for the array implementation of the Heap ADataType // //--------------------------------------------------------------------

#ifndef HEAP_H #define HEAP_H

#include #include

using namespace std;

template class Less { public: bool operator()(const KeyType &a, const KeyType &b) const { return a

template > class Heap { public:

static const int DEFAULT_MAX_HEAP_SIZE = 10; // Default maximum heap size

// Constructor Heap ( int maxNumber = DEFAULT_MAX_HEAP_SIZE ); // Default constructor + basic constr Heap ( const Heap& other ); // Copy constructor Heap& operator= ( const Heap& other ); // Overloaded assignment operator

// Destructor ~Heap ();

// Heap manipulation operations void insert ( const DataType &newDataItem ) // Insert a data item throw ( logic_error ); DataType remove () throw ( logic_error ); // Remove max priority element void clear (); // Clear heap

// Heap status operations bool isEmpty () const; // Heap is empty bool isFull () const; // Heap is full

// Output the heap structure -- used in testing/debugging void showStructure () const;

// Programming exercise #3 operation void writeLevels () const; // Output in level order

private:

// Recursive helper of the showStructure() function void showSubtree ( int index, int level ) const;

// Data members int maxSize, // Maximum number of elements in the heap size; // Actual number of elements in the heap DataType *dataItems; // Array containing the heap elements

Comparator comparator; };

#endif //#ifndef HEAP_H

Thank YOu

Heap ADT Type. Each data item has heap Data items seneric e rahe within the to in a heap are relative that priorities are "or obiects Note priority, The is to additional operators, as imetion etyve it quite that basic relational usually likely six item's Type must the data Data returns a ity that eatra For each data item E in the tre an of Structure complete or equ to Es priority The data items form a are less than have Operations HEAP. 12E) Reap int max Number MAx Requirements None memory for a heap Constructor, creates an empty heap. A enough Number data items, containi Heap const He other Requirements Results: the object to be an equivalent copy of other. copy constructor. Initializes Heap& operator const Heap other Requirements None Results heap to be equivalent to the other Heap and overloaded assignment operator. Sets the returns a reference to this object. -Heap Requirements: None Results: Destructor. Deallocates (frees the memory used to store the heap

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!