April 2018
Intermediate to advanced
322 pages
6h 57m
English
Fetching the element's maximum value is quite simple since it is stored in the root, or, in other words, it's in index 1. To do so, we just need to return vect[1]:
int BinaryHeap::GetMax(){ // Return root's key return vect[1];}
Since it's a simple implementation, the time complexity for the GetMax() operation is O(1).