0

I know basic heap operations like insertion,deletion,finding minimum etc.I know deletion at certain index like deletion of element present at index 2 or so,but how to delete if we are to delete certain value that is present in the heap ?

In my opinion first we have to find the position of the certain element and than have to delete like we usually do.Pseudo code is welcome.

My question is :- How to delete certain valued element from heap and what will be the overall time complexity ?

  • 1
    Deleting is easy, but finding a specific element takes O(N) time. If you need to be able to find and remove specific elements quickly, you should use a binary search tree or similar data structure – Matt Timmermans Jan 05 '16 at 14:11
  • @amit thanks for your response.It was really a weird question.Finding index in O(n) passed like flying colors.Thanks a lot and sorry I didn't know that it is a duplicate question :) – thoughtful me Jan 06 '16 at 08:52
  • @MattTimmermans thanks a lot for your valuable suggestion :) – thoughtful me Jan 06 '16 at 08:52

0 Answers0