Red/black tree boundary condition settings

Source: Internet
Author: User

The boundary seems to be an algorithm problem, but the data structure has the responsibility to optimize its own structure to simplify the algorithm's judgment on the boundary.

In the red/black tree, a head node (center-left) is generated in the data structure to facilitate the detection of the boundary conditions. The parent pointer of the node is null, and the left and right pointers point to themselves respectively. After a node (root node) is inserted, the pointer is updated, as shown in figure: the head node and the root node use the parent pointer to each other, and both the left and right nodes of the head node point to the root node. This structure helps later traversal and other algorithms to determine the boundary conditions.

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.