Draw the corresponding Red–Black tree for the given 2–3–4 tree below.Draw the corresponding 2–3–4 tree for the given Red–Black tree.

CS 251 – Data Structures and Algorithms Fall 2022
Question 1
The Left–Leaning Red–Black tree is a variant of a Red–Black tree, which is a lot easier to implement in code. Considering the general Red–Black tree, which does not require red nodes to be linked to the left. That is, a node could have a left red child, or a right red child, or even two red children. But a red node must have black children. Like that Left–Leaning Red–Black tree represents 2–3 tree, the general
Red–Black tree represents 2–3–4 tree, where a node is allowed to have 1 key and 2 links , or 2
keys and 3 links (3–nodes), or 3 keys and 4 links (4–nodes).
• A 2–node in 2–3–4 tree is a black node with no red child in RB tree.
• A 3–node in 2–3–4 tree is a black node with 1 red child in RB tree.
• A 4–node in 2–3–4 tree is a black node with 2 red children in RB tree.
As shown in the following figure:
a) Draw the corresponding Red–Black tree for the given 2–3–4 tree below:
b) Draw the corresponding 2–3–4 tree for the given Red–Black tree:
c) Considering the insert operation in 2–3–4 tree and RB tree:
1. If a key is inserted into a 2–node, the 2–node becomes a 3–node.
2. If a key is inserted into a 3–node, the 3-node becomes a 4–node.
3. If a key is inserted into a 4–node, firstly, the middle value in the 4–node is added to the father node , and the left and right values becomes two 2–nodes children. Then, new key is inserted into the corresponding child and makes it to a 3–node.
2
CS 251 – Data Structures and Algorithms Fall 2022
The corresponding rules of insert operation in Red–Black tree are:
1. If a key is inserted into a black node with no red child, then insert it as a
red child to that node.
2. If a key is inserted into a black–red subtree , then the result needs to be
transformed to a black node with 2 red children.
3. If a key is inserted into a red–black–red subtree , then the result needs to be
transformed to a red father with 2 black children and 1 red grandson.
As shown in the following figure:
Now consider the 2–3 tree and Red–Black tree below. Draw both trees after each of the following operations is executed: insert(9), insert(6), insert(8), insert(10), insert(11).

Last Completed Projects

topic title academic level Writer delivered
© 2020 EssayQuoll.com. All Rights Reserved. | Disclaimer: For assistance purposes only. These custom papers should be used with proper reference.