public class SearchTree> { private SearchTreeNode overallRoot; // post: constructs an empty tree public SearchTree() { overallRoot = null; } // pre: tree satisfies the binary search tree property // post: value is added to overall tree so as to preserve the // binary search tree property public void add(E value) { overallRoot = add(overallRoot, value); } // post: value is added to given tree so as to preserve the // binary search tree property private SearchTreeNode add(SearchTreeNode root, E value) { if (root == null) { root = new SearchTreeNode(value); } else if (value.compareTo(root.data) <= 0) { root.left = add(root.left, value); } else { root.right = add(root.right, value); } return root; } // post: prints the data of the tree, one per line public void print() { System.out.print("preorder:"); printInorder(overallRoot); System.out.println(); } // post: prints in inorder the tree with given root private void printInorder(SearchTreeNode root) { if (root != null) { printInorder(root.left); System.out.print(" " + root.data); printInorder(root.right); } } }