Lazy Sign of binary heap

Source: Internet
Author: User

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.

  1. 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.
  2. 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:
    1. Move to the top of the heap and adjust the heap;
    2. Remove this element again and adjust the heap again.
    3. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.