Skip to main content

rotateRight

Short summary

rotates right around a specified node, doesnt care about balance and stuff, this is done in method reorganizeRightRotate

Return: the new root

Parameters

NameTypeCommentKind
elemCNM_CollectionInterfaces.IBalancedBinarySearchTreeNodethe element that should be rotatet aroundinput

Code

Declaration

METHOD PROTECTED rotateRight :CNM_CollectionInterfaces.IBalancedBinarySearchTreeNode
VAR_INPUT
(*the element that should be rotatet around*)
elem :CNM_CollectionInterfaces.IBalancedBinarySearchTreeNode;
END_VAR
VAR
newRoot :CNM_CollectionInterfaces.IBalancedBinarySearchTreeNode;
END_VAR

Implementation

__QUERYINTERFACE(elem.leftChild,newRoot);
elem.leftChild := newRoot.rightChild;
newRoot.rightChild := elem;
rotateRight := newRoot;