CSIS 3103 - Assignment 4 : Binary Tree Iterator
Fall 2010


Goals:

Source code: BinaryTree.java, BinarySearchTree.java

Problem Description:

A) See Programming Project 8 on p. 357 that describes an Iterator for the BinaryTree class. Modify the BinaryTree class to implement the Iterable interface as described.

B) Since the BinarySearchTree class extends BinaryTree, it will inherit the iterator capability.

Add a class with a main method to the project. Have it build a BinarySearchTree of Integer elements by adding at least 100 random integers to the tree. Then use an iterator to calculate the sum of all the even numbers in the tree.

C) Add another class with a main method. In this class, implement a method called printWordsStartingWith. This method should take a BinarySearchTree and a character as parameters, and print all elements in the tree that start with the specified letter.

Have the program read a text file and build a binary search tree with the words found in the file (convert all letters to lower case). Then use the printWordsStartingWith method to print sublists of words starting with each letter of the alphabet.

Submissions:

Submit the .java files for your project.