Page 1 of 1

Implement a class template MinHeap that has the following declaration: class MinHeap { Node* heap; //an array of nodes i

Posted: Thu Jun 02, 2022 8:27 am
by answerhappygod
Implement a class template MinHeap that has the following declaration:
class MinHeap {
Node* heap; //an array of nodes
int _size; //size of array public:
Node extractMin(); //returns & removes the node with minimum cost
void buildMinHeap(Node[],int);// allocates array then builds a min-heap from an array of struct Node with the given size
void minHeapify(int i, int n);//restores the min-heap property for the “heap” array using the given index and size n
void decreaseKey(char label,int newCost);//decreases the node that has the given label to newCost
int parent(int i);//returns the index of the parent of i
int getSize();//returns size of the heap
bool inHeap(char);//checks if the node with the given label is in the heap
};
using c++ language