duplicates are not allowed, What will be the answer if we were asked to find the
If elements are repeated, then also this holds true. Consider the heap array 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 4 5 6 7 The given procedure returns 1 and that is the correct answer. “7" must be returned only if the questions asks "7th" distinct smallest element which might require entire scanning of the heap and needs a hashtable to be run in $O(n)$ time
Source: Arjun sir comment
It will take O(1)
64.3k questions
77.9k answers
244k comments
80.0k users