Convention: The linear Table A represents the binary heap h,a with 0 marking.
Typically, the deletion of a heap takes place at the top of the heap H, or a[0], but what if you want to delete the other nodes? Under the premise of maintaining the nature of the heap, it is difficult to solve it by conventional method. You can use the lazy tag of the two fork heap at this time.
- To delete 1 nodes, do nothing first, just add this node to the collection A to be deleted. The subsequent find operation without deleting the two fork tree has no effect.
- The next time the heap top element is ejected (deleted), the first view is whether the a collection is empty, or not empty, and the element will do the following:
- Move to the top of the heap and adjust the heap;
- Remove this element again and adjust the heap again.
- Remove this element from a
In doing so, the total time complexity is still the same as the general binary heap, but it is relatively unbalanced.
Lazy Sign of binary heap