Please explain/justify/prove your answer to your answer to this question: In constant time for a min-heap is it possible for someone to implement both deleteMin(used for deleting the min element) and insert (used for inserting one element)? (in c++ language) please type answer if you can
`Hey,
Note: If you have any queries related to the answer please do comment. I would be very happy to resolve all your queries.
No it isn't possible to have deletemin or insert in constant time. The reason is because when we delete a minimum we need to place some elements from its child and that should be the minimum of its child. Now whichever child is made minimum we need to have its child too adjusted. So, this adjustment would go along the height of heap and will be indeed O(log(n)) operation
Kindly revert for any queries
Thanks.
Get Answers For Free
Most questions answered within 1 hours.