public class TreeExample> extends Tree { // for real implementations this would be much more complicated public boolean add(T o) { root.add(new TreeNode(o)); return true; } public boolean remove(T o) { throw new UnsupportedOperationException(); } public static void main(String[] args) { Tree t = new TreeExample<>(); t.root=new Tree.TreeNode("ARSENAL"); t.root.add(new Tree.TreeNode("Forty")); t.root.add(new Tree.TreeNode("Nine")); t.root.add(new Tree.TreeNode("Undefeated")); t.root.children.get(0).add(new Tree.TreeNode("I")); t.root.children.get(0).add(new Tree.TreeNode("Bet")); t.root.children.get(1).add(new Tree.TreeNode("You")); t.root.children.get(2).add(new Tree.TreeNode("Are")); t.root.children.get(2).add(new Tree.TreeNode("Sick")); t.root.children.get(2).add(new Tree.TreeNode("Of")); t.root.children.get(2).add(new Tree.TreeNode("Arsenal")); t.root.children.get(2).children.get(1).add(new Tree.TreeNode("Examples")); String[] testy={"Arsenal","Totts"}; System.out.println("iterative breadth first search:"); for (String s : testy) { if (t.iterativeBreadthFirstContains(s)) { System.out.println("Tree contains " + s); } else { System.out.println("Tree doesn't contain " + s); } } System.out.println("recursive depth first search:"); for (String s : testy) { if (t.recursiveDepthFirstContains(s)) { System.out.println("Tree contains " + s); } else { System.out.println("Tree doesn't contain " + s); } } System.out.println("iterative breadth first search:"); for (String s : testy) { if (t.iterativeDepthFirstContains(s)) { System.out.println("Tree contains " + s); } else { System.out.println("Tree doesn't contain " + s); } } System.out.println("\nbreadth first iteration"); for (String s : t.new BreadthFirstIterator()) { System.out.println(s); } } }