Skip to content

RightRotation ​

Rotate the root to the right: the left child becomes the root, the root its right child.

RightRotation(BinaryTree)Rotate the root to the right: the left child becomes the root, the root its right child.
Typed signatures
TypePackageApplies
(binary_tree) -> binary_treecombinatoricsalways

Domain: Combinatorial maps

Details
  • Takes a BinaryTree and returns a BinaryTree — a typed map, so a wrong carrier is a type error rather than a wrong answer.
  • FindStat's Mp00019. A tree whose root has no left child has nothing to rotate; FindStat then moves its right subtree to the left, as [A, .], and so do we. That makes it a bijection on every size, inverse to LeftRotation.

Examples

Basic #

a four-node tree

live ↗
InRightRotation(BinaryTree⁡([[0,0],[0,[0,0]]]))\mathrm{RightRotation}({\operatorname{BinaryTree}}(\bigl\lbrack\bigl\lbrack0, 0\bigr\rbrack, \bigl\lbrack0, \bigl\lbrack0, 0\bigr\rbrack\bigr\rbrack\bigr\rbrack))OutBinaryTree⁡([0,[0,[0,[0,0]]]]){\operatorname{BinaryTree}}(\bigl\lbrack0, \bigl\lbrack0, \bigl\lbrack0, \bigl\lbrack0, 0\bigr\rbrack\bigr\rbrack\bigr\rbrack\bigr\rbrack)
About
Examples1
CrosswalkFindStat