I have a final coming up and the professor has hinted in class that there would be a question on how to make the primitive min operation in Big-O(1). I know that its capable of and how it works in Big-O(log n). I have idea that it will involve the use of pointers. The exam is Tuesday.

Recommended Answers

All 2 Replies

Its very obvious that IN MIN HEAP , the smallest element will sit at the top of the tree ,hence to search the smallest element in the heap , it takes constant time i.e O(1)

Or just store a copy of the min element alongside whatever data structure you want and you can then access it in O(1) time.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.