A right array rotation by sends the entry originally at offset to offset for nonempty length . Equivalently it changes adjacent blocks into when . Identity rotations include and .
Three reversals implement the operation: . Alternatively repeatedly use a block swap to put the smaller block in its final position and recurse on the remaining unresolved segment. Replacing that tail recursion by parameter updates gives constant auxiliary storage. If counts swaps for blocks of lengths , then and for unequal lengths. The Euclidean algorithm shows by induction that , so a right rotation uses element swaps for .
New to topics? Read the docs here!