public T rMax(BinaryNode<T> node, T max) { if (!isEmpty()) { if (node.hasLeftChild()) max = rMax(node.getLeftChild(), max); if (node.hasRightChild()) max = rMax(node.getRightChild(), max); if (max == null) max = node.getData(); else if (max.compareTo(node.getData()) == -1) max = node.getData(); } return max; }
public T rMin(BinaryNode<T> node, T min) { if (!isEmpty()) { if (node.hasLeftChild()) { min = rMin(node.getLeftChild(), min); } if (node.hasRightChild()) { min = rMin(node.getRightChild(), min); } if (min == null) // if neither side has a child, set min to the node { min = node.getData(); } else if (min.compareTo(node.getData()) == 1) { min = node.getData(); } } return min; }