October 2025
Intermediate to advanced
485 pages
13h 2m
English
These are the solutions to the Exercises.
As with a BST, we’d make the L a right child of the K. Since the L has a greater priority than its parent, the K, we don’t need to enter a fixing phase. Therefore, the treap will look like the tree shown after inserting the L.

As with the previous exercise, we start by inserting the L as the K’s right child. However, because the L has a priority that is less than any other node in the treap, we must rotate the L up the treap until it becomes the root. After all the rotations are made, the treap will look like this:
We delete the Q node by rotating it downward through the treap. Which child ...
Read now
Unlock full access