Time complexity to get min elements from max-heap

后端 未结 6 2397
渐次进展
渐次进展 2020-12-28 18:46

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

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-28 19:24

    MINIMUM_ELEMENT -> it will take O(n) time in case of Max heap and O(1) in case of Min heap. MAXIMUM_ELEMENT -> it will take O(1) time in case of Max heap and O(n) in case of Min heap.

提交回复
热议问题