in min heap, we know that 7th minimum will be present maximum till 7th level, and there will 127 elements till 7th level, so we have to do only constant time comparison, and it will take O(1) time.

The Gateway to Computer Science Excellence

0 votes

In a binary min heap with n elements, the 7th smallest element can be found in _____ ?

Answer given is O(logn)

and solution:-

Delete the 1st smallest element O(logn)

Delete the 2nd smallest element O(logn)

....

Delete the 7th smallest element O(logn).

So in total O(logn).

In this solution the data arrangement of the heap will be changed after performing these operation.

any better solution than this???

Answer given is O(logn)

and solution:-

Delete the 1st smallest element O(logn)

Delete the 2nd smallest element O(logn)

....

Delete the 7th smallest element O(logn).

So in total O(logn).

In this solution the data arrangement of the heap will be changed after performing these operation.

any better solution than this???

52,218 questions

59,856 answers

201,041 comments

118,103 users