I was asked in an interview:
What is the best time complexity in getting the min element(s) from a max-heap?
I replied as O(1) a
Best complexity is O(n).
Rather than, not wrote here a lot about that,
The min element in MAX-heap, and the MAX element in min-heap
Can be also at the (lowest level - 1) and not always in lowest level.
explain:
because in heap there is an option of missing nodes from the right side of the lowest level, it could be not a balancing (fully) tree, what makes it to have leafs also in (lower level -1).
what means that there are n/2 to check. so in big O term it's equal to O(n).
Examples for situation like that: