Proof: In the RB-DELETE, if y is red, then when y is deleted, the red and black properties are maintained

Source: Internet
Author: User

In the RB-DELETE, when y is black, the RB-DELETE-FIXUP function is called to adjust the color of the Red-black tree, which means that if y is red, there is no need to adjust it, next we will prove the correctness of this proposition.

 

First, the properties of the red and black trees 1) and 3) are obviously satisfied. For properties 2), 4) and 5) are discussed in three cases.

 

In case 1), the deleted node Z has only the black sentinel node. In this case, y = Z and Y will not affect the black height of the red/black tree, Y is red, it cannot be the root, and it cannot cause two red nodes to be adjacent. Therefore, the properties 2), 4), and 5 are satisfied.

 

In case 2), one of the subnodes of the deleted node Z is a black Sentinel, and the other is a common node with Y = Z. In fact, it is impossible for y to be a red node, because if the common node is black, it will make the black height of the red and black tree inconsistent, violating the nature 5). If it is red, it will violate the Nature 4 ).

 

In case 3), the deleted Z node has two normal sub-nodes. In this case, y = tree-successor (Z), If y is a red node, both children of Y must be nil [T]; otherwise, it will violate the nature of the red and black trees. Therefore, after deleting y, the remaining red and black trees, for properties 2), 4) and 5), both are satisfied.

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.