Question: Given the class definitions below, complete the code for the empty, swap and push functions.( thats Heap. Binary Heap. in data structure class by using
Given the class definitions below, complete the code for the empty, swap and push functions.( thats Heap. Binary Heap. in data structure class by using c++)
#include #include using namespace std; class heapType{ public: bool empty(); void push(int num); heapType();
private: int C1I; int C2I; int CI; int done; // status flag int EOL; // end of line int count; // elements in the heap int heap[10];
int PI; // parent index
void swap(int I1,int I2); // exchange heap contents };
// ----------------------------------------------------- bool heapType::empty(){
... complete the code here ...
} // ----------------------------------------------------- void heapType::swap(int I1,int I2){ // exchange heap contents
... complete the code here ...
} // ----------------------------------------------------- void heapType::push(int num){
... complete the code here ...
// child 1 index // child 2 index // child index
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
