1: // Corrects an imbalance at the node closest to a structural
2: // change in the left subtree of the node's left child.
3: // nodeN is a node, closest to the newly added leaf, at which
4: // an imbalance occurs and that has a left child.
5: private BinaryNode<T> rotateRight(BinaryNode<T> nodeN)
6: {
7: BinaryNode<T> nodeC = nodeN.getLeftChild();
8: nodeN.setLeftChild(nodeC.getRightChild());
9: nodeC.setRightChild(nodeN);
10: return nodeC;
11: } // end rotateRight
12:
13: // Corrects an imbalance at the node closest to a structural
14: // change in the left subtree of the node's right child.
15: // nodeN is a node, closest to the newly added leaf, at which
16: // an imbalance occurs and that has a right child.
17: private BinaryNode<T> rotateRightLeft(BinaryNode<T> nodeN)
18: {
19: BinaryNode<T> nodeC = nodeN.getRightChild();
20: nodeN.setRightChild(rotateRight(nodeC));
21: return rotateLeft(nodeN);
22: } // end rotateRightLeft
23: // Version 4.0