1.

The procedure FindMin() to find the minimum element and the procedure DeleteMin() to delete the minimum element in min heap take _________(a) logarithmic and linear time constant respectively(b) constant and linear time respectively(c) constant and quadratic time respectively(d) constant and logarithmic time respectivelyThe origin of the question is Heap topic in chapter Heap of Data Structures & Algorithms IThis question was posed to me in exam.

Answer»

The correct option is (d) constant and logarithmic TIME respectively

The best I can explain: In the min heap, the root is the maximum element in the tree. So, LOCATING it takes constant time, but deleting it takes logarithmic time. Because after deleting it, the root is replaced with LAST element and then the PROCEDURE to maintain the min ORDERING is invoked.



Discussion

No Comment Found

Related InterviewSolutions