ZIG [00UH]

If x is the child of the root of the whole tree, then just do one rotation to move it to the root.

A, B, and C denote arbitrary subtrees. We don’t do anything to them at all, so the rotation takes constant time; we just need to update a few references. In the diagram, x is the left child of the root, so we rotate right, but there is also a second entirely symmetric case when x is the right child of the root and we rotate left.

Note how doing a rotation moves x up while preserving the binary search tree properties: all the elements in the subtree A are still to the left of x; all the ements in B remain in between x and p; and C remains to the right of p.