// Erika Wolfe, CSE 143 // This class represents a tree of integers public class IntTree { private IntTreeNode overallRoot; // Constructs a tree with default numbers public IntTree() { overallRoot = null; } // prints the numbers in this tree in a pre-order fashion. public void print() { print(overallRoot); } // prints the numbers of the subtree beginning at root // using a pre-order traversal. private void print(IntTreeNode root) { if (root != null) { System.out.print(root.data + " "); // print the left print(root.left); // print the right print(root.right); } } // Returns the number of numbers in this tree. public int size() { return size(overallRoot); } // Returns the number of nodes in the tree starting at root. private int size(IntTreeNode root) { if (root == null) { return 0; } else { int leftSize = size(root.left); int rightSize = size(root.right); return 1 + leftSize + rightSize; } } }