Java Reference
In-Depth Information
private int min(IntTreeNode root) {
if (root.left == null) {
return root.data;
} else {
return min(root.left);
}
}
// max is written in the same fashion, but with 'max' and
// 'right' in place of 'min' and 'left'.
26. When we are converting the tree to store type E , we must add a type parameter to
the class header. This parameter must be Comparable . When we are examining
whether a given element is too small or large (whether to go left or right recur-
sively) in methods such as add or contains , we must call compareTo instead of
using the < and > operators that do not work with objects.
27. To add a tree iterator, our nodes would need to have references to their parents so
that the iterator could go back up the tree as necessary when traversing through the
elements.
 
Search WWH ::




Custom Search