The heapSize variable can be used to indicate whether or not the heap is empty. We just need to check if heapSize = 0 to determine that the heap is empty. The following is an implementation of the IsEmpty() operation:
bool BinaryHeap::IsEmpty(){ // Heap is empty if only // heapSize = 0 return heapSize == 0;}
The preceding sample code will run on O(1) since it's just simply getting the heapSize value.