1: // Removes the node containing the largest entry in a given tree.
2: // rootNode is the root node of the tree.
3: // Returns the root node of the revised tree.
4: private BinaryNode<T> removeLargest(BinaryNode<T> rootNode)
5: {
6: if (rootNode.hasRightChild())
7: {
8: BinaryNode<T> rightChild = rootNode.getRightChild();
9: rightChild = removeLargest(rightChild);
10: rootNode.setRightChild(rightChild);
11: }
12: else
13: rootNode = rootNode.getLeftChild();
14:
15: return rootNode;
16: } // end removeLargest
17: // Version 4.0