Write . After splaying on , that key is at the root, and is the smallest key in its right subtree. This uses the integer assumption: no stored key lies strictly between and . Thus has an empty left subtree while it remains within the right subtree of .
Now perform ordinary bottom-up splaying on . Until the final step involving , all tree rotations occur below and leave it at the root. There are only two possible final cases.
  • If is the right child of , a single zig step rotates above , placing immediately to its left.
  • Otherwise is a grandchild of . Its parent lies in the right subtree of and must satisfy . Hence the last two directions are right then left. A zig-zag step rotates above and then above , again placing immediately to its left. A right-right final configuration is impossible because is the minimum of this subtree.
Therefore becomes the left child of . The argument applies more generally to consecutive keys in a binary search tree, even when their numerical difference is not one.

Articles by others on the same topic (0)

There are currently no matching articles.