2 votes 2 votes The time required to determine the minimum element from the max heap of size O(log(n)) is given by DS data-structures binary-heap time-complexity applied-gate-test-series + – LRU asked Nov 3, 2021 • recategorized Jul 8, 2022 by Lakshman Bhaiya LRU 848 views answer comment Share Follow See all 2 Comments See all 2 2 Comments reply Chandrabhan Vishwa 1 commented Nov 3, 2021 reply Follow Share in max heap the smallest element always belong at leaf node and total leaf node on the last level is approx n/2 compare it is equal to O(n) in this question heap size logn so it is O(logn) 0 votes 0 votes Awe111 commented Nov 3, 2021 reply Follow Share @LRU Min element from Max heap : 1. search at last level = O(n/2)= O(n) … replace searched element with last element and decrease heap size by 1 = O(1).. Apply Maxheapify on replaced element = O(log n) Total Time … Total Time = O(n)+O(1)+O(log n) = O(n).. In this question heap size logn , so it is O(logn)... 1. https://gateoverflow.in/889/Gate-cse-2006-question-10 2. https://gateoverflow.in/295138/Finding-the-minimum-element-in-a-heap 1 votes 1 votes Please log in or register to add a comment.
Best answer 4 votes 4 votes Max element can be present in any of the leaf nodes of a min-heap.In a heap, the tree is a complete binary tree so the minimum element will be present either in the lowest level or second-lowest level, Now the number of elements we have to check(elements present in lowest and second-lowest level) is O(logn). So just by doing a linear search, you will get the element. Answer : O(logn). Ref: algorithm - Time complexity to get min elements from max-heap - Stack Overflow https://gateoverflow.in/295138/Finding-the-minimum-element-in-a-heap https://gateoverflow.in/889/Gate-cse-2006-question-10 raja11sep answered Nov 3, 2021 • selected Jan 3, 2022 by LRU raja11sep comment Share Follow See all 0 reply Please log in or register to add a comment.