A new 2-3 tree is created. Explain the steps in inserting the following elements in this order into the initially empty tree: 13, 23, 17.
What will be an ideal response?
tree is initially empty.
Inserting 13 involves creating a node for the root and inserting the element with 13 into it. The root element is now a 2-node
and is a leaf node. The tree looks like this:
(13)
Inserting 23 into the tree containing 13 involves adding the element 23 to the leaf node containing 13. The root node is now a
3-node and is still a leaf node. The tree looks like this:
(13 23)
Inserting 17 into the tree involves locating the leaf node for the insertion, which is the root node, then adding it to the node.
However, the node cannot hold another element, so it is split, and the middle element, 17, is moved up. A new root node is
created and 17 is added to it, with the node containing 13 as the left node and the node containing 23 as the right node. The
root node has 17. The tree looks like this:
(17)
/ \
(13) (23)
All nodes are now 2-nodes. The nodes containing 13 and 23 are leaf nodes.
You might also like to view...
There are seven different tab types in Word
Indicate whether the statement is true or false
Give an example of a command that uses grep
a. With both input and output redirected. b. With only input redirected. c. With only output redirected. d. Within a pipeline.