If you create your heap with those numbers, you'd end up with 5 as one of the child nodes of 100 so finding it is a O(1) operation.
Momerath
Senior Poster
3,729 posts since Aug 2010
Reputation Points: 1,322
Solved Threads: 624
Skill Endorsements: 13
Maybe it's your ASCII art, but that doesn't look like a heap from where I'm sitting. 100 can't be both a child of 1 and a parent of 3.
By the heap property, if the node containing the max element of the tree is not the root, then that node must be in the bottom row - depends on how your heap's structured, but it's one or the other. So as stated, the node to be removed is in the bottom row, and it's a one-step operation to remove it.
jon.kiparsky
Posting Virtuoso
1,849 posts since Jun 2010
Reputation Points: 383
Solved Threads: 187
Skill Endorsements: 3
It's a worst case O(log(n)) operation but you can be pretty sure the expected running time is O(1) (given a heap formed from a uniformly selected permutation of an array).
Rashakil Fol
Super Senior Demiposter
2,732 posts since Jun 2005
Reputation Points: 1,153
Solved Threads: 182
Skill Endorsements: 25