/** * Tests of an implementation of the basics of a binary search tree: * find, add, and toString. * * @author David Mutchler. * Created October, 2008. */ public class Main { /** * Tests of an implementation of the basics of a binary search tree: * find, add, and toString. * * @param args Command-line arguments (ignored here). */ public static void main(String[] args) { BinarySearchTree tree = new BinarySearchTree(); tree.add("bilbo", "hobbit"); tree.add("gandalf", "dwarf"); tree.add("frodo", "frodo's nephew"); System.out.println(tree.find("gandalf")); System.out.println(tree.find("bilbo")); System.out.println(tree.find("frodo")); System.out.println(tree.find("sam")); System.out.println(tree.toString()); tree.add("sam", "loyal hobbit"); tree.add("aargh", "pirate curse"); System.out.println(tree.find("gandalf")); System.out.println(tree.find("gandalf")); System.out.println(tree.find("bilbo")); System.out.println(tree.find("frodo")); System.out.println(tree.find("sam")); System.out.println(tree.find("aargh")); System.out.println(tree.find("oops")); System.out.println(tree.toString()); } }