1.

In a binary min heap containing n elements, the largest element can be found in __________ time.(a) O(n)(b) O(nlogn)(c) O(logn)(d) O(1)The doubt is from Heap in portion Heap of Data Structures & Algorithms IThe question was asked in an online interview.

Answer»

Right answer is (a) O(n)

The best I can EXPLAIN: In MIN heap the SMALLEST is located at the root and the largest elements are located at the leaf nodes. So, all leaf nodes need to be checked to find the largest element. Thus, worst case TIME will be O (n).



Discussion

No Comment Found

Related InterviewSolutions