Skip to content

LeftRotation ​

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

LeftRotation(BinaryTree)Rotate the root to the left: the right child becomes the root, the root its left 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 Mp00009. A tree whose root has no right child has nothing to rotate; FindStat then moves its left subtree to the right, as [., A], and so do we. That makes it a bijection on every size, inverse to RightRotation.

Examples

Basic #

a four-node tree

live ↗
InLeftRotation(BinaryTree⁡([[0,0],[0,[0,0]]]))\mathrm{LeftRotation}({\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\lbrack\bigl\lbrack\bigl\lbrack0, 0\bigr\rbrack, 0\bigr\rbrack, \bigl\lbrack0, 0\bigr\rbrack\bigr\rbrack)
About
Examples1
CrosswalkFindStat