18.6 Exercises
Last updated
Last updated
Consider the tree below. If we call rotateLeft(C)
, which operation reverts the tree back to its original form?
When you rotate a nodes in a tree, which of the following can happen?
Consider the following LLRB. What is the height of the corresponding 2-3 tree and how many 3-nodes does it have?
Suppose we insert 15
in the LLRB above. What is the first operation that must be applied to maintain the LLRB invariants?
Suppose in the process of insertion, we end up with the following temporary 4-node. What is the corresponding LLRB representation of this node?
Give a range of values, when inserted into the LLRB below, results in a rotateRight
operation as the first balancing operation. Assume that values are distinct, but not necessarily integers.
rotateRight
occurs when we have two red links in a row. This occurs when we insert to the left of 39
. This value must be larger than 25
(since it is in its right branch) but less than 39
(since it is the left child of 39). So our final range is .