Skip to content
IT Nursery
  • Home
  • Programming
    • Mac / IOS
    • Android
    • Web Applications
    • PHP
    • Java
    • C
    • C++
  • DataBase
    • MySQL
  • CMS
    • WordPress
  • System and Network
    • Serverfault

Converting a 2-3-4 tree into a red black tree

by IT Nursery

Consider these three rules:

  1. Transform any 2-node in the 2-3-4 tree into a black node in the red-black tree.
  2. Transform any 3-node into a child node and a parent node. The child node has two children of its own: either W and X or X and Y. The parent has one other child: either Y or W. It doesn’t matter which item becomes the child and which the parent. The child is colored red and the parent is colored black.
  3. Transform any 4-node into a parent and two children, the first child has its own children W and X; the second child has children Y and Z. As before, the children are colored red and the parent is black.

The red-black rules are automatically satisfied if you follow these rules. Here’s the resulting example tree after applying the transformations.

Hopefully that should get you going. For easy to understand and detailed explanation, you can refer to Robert Lafore’s Data Structures book.

Categories Java

Leave a Comment Cancel reply

Recent Posts

  • Advice for improving internal dashboard [closed]
  • grep : ‘+’ special character
  • File location for Syslogs in Centos machine
  • How to collect users’ task completion times?
  • “service {FOO} start” vs. “/etc/init.d/{FOO} start”? [closed]
IT Nursery
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Important Link

  • About
  • Privacy Policy
  • Contact

IT Nursery

The Goal of ITNursery Engaging the world to foster innovation through aggregate information. Our Question Answer post, blog information, products and tools help developers and technologists in life and at work.

copyright © 2023 All Right Reserved | IT NurSery