class TreeSet> { private static class Node { T item; Node left, right; Node(T item0, Node left0, Node right0) { item = item0; left = left0; right = right0; } } private Node root = null; private int numItems = 0; public TreeSet() { root = new Node(null, null, null); numItems = 0; } public TreeSet(T t) { root = new Node(t, null, null); numItems = 1; } public boolean contains(T t){ Node currentNode = root; boolean found = false; for(int i = 0; i <= numItems; i++){ if(currentNode.item.compareTo(t) == 0) { found = true; } else { if(currentNode.item.compareTo(t) > 0) { currentNode = currentNode.left; } else if(currentNode.item.compareTo(t) < 0) { currentNode = currentNode.right; } } if(currentNode == null) { return false; } } return found; } }