ZIG-ZIG [00UI]

If x and p are either both left children or both right children, then do two successive rotations: first rotate around g \to p then around p \to x.

Some things to note:

  • This rule applies anywhere in the tree, unlike ZIG which only applies when x is at a depth of 1. After applying ZIG-ZIG, x has moved two levels closer to the root.
  • Like ZIG, this takes constant time, since we just do two rotations.
  • Again, in the picture x and p are illustrated as both being left children, but there is an analogous symmetric case when x and p are both right children.