Transformation Methods of 2-3-4 trees and red/black trees

Source: Internet
Author: User

2-3-4 trees and red/black trees may look completely different. However, in a sense, the two are exactly the same.

 

There is a data item and two subnodes are called 2-nodes.

There are two data items and three sub-nodes called 3-nodes.

Three data items and four subnodes are called 4-nodes.

 

Rules for converting from 2 to 4 trees to red/black trees

1. Each 2-node in the 2-4-4 tree is converted to a black node in the red/black tree.

2. 3-the node is converted into a subnode and a parent node. The subnode has two subnodes. The parent node has another subnode.

The child node becomes red, and the parent node becomes black.

3. 4-the node is converted into a parent node and two child nodes. The first subnode has its own subnode. The second subnode has its own two subnodes. The child node becomes red, and the parent node becomes black.

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.