Height-maintaining pointer-machine AVL rotation #
A concrete program saves the old root, rotates links, recomputes the old root's height, then follows its parent to recompute the promoted root's height. All primitive blocks are relocated into one finite program, including their charged continuation jumps. The external parent's child link is left for the caller to reconnect.
Wrap a pointer rotation with saving its former root and repairing both pivot heights. The supplied block must leave the former root's parent pointing to the promoted root. The certified entry points below supply the concrete left and right rotations.
Right subtree rotation followed by bottom-up recomputation of both pivot heights. Data temporaries one/two and pointer registers zero/two/three/four/six may change.
Left subtree rotation followed by bottom-up recomputation of both pivot heights. Data temporaries one/two and pointer registers zero/two/three/four/six may change.
A concrete right rotation implements the existing AVL rotation's two cached-height updates in 39 instructions. The three untouched child trees need correct caches; the two pivot caches may initially be arbitrary. External-parent reconnection is separate.
A concrete left rotation implements the existing AVL rotation's two cached-height updates in 39 instructions. The three untouched child trees need correct caches; the two pivot caches may initially be arbitrary. External-parent reconnection is separate.