/** * A public interface for Binary Trees * @author gtowell * Created: March 2020 */ public interface BinaryTreeInterface { /** * @return the number of items in the tree */ int size(); /** * * @return the maximum number of links between * the root of the tree and the most distant leaf */ int height(); /** * @return return true if the tree has no nodes */ boolean isEmpty(); /** * @return true if the given element exists in the tree and false otherwise */ boolean contains(E element); /** * Add an element to the tree (if the element does not already exist * in the tree) If the element already is in the tree, do nothing. * @param element the element to be added */ void insert(E element); /** * Remove something from the tree * @param element the element to be removed * @return element if it was in the tree, null otherwise */ boolean remove(E element); /** * return a string containing the items in the tree on a single line in the natural * order arising from their type. That is, numbers should be in numeric order; * strings in alphabetic order. All items should be on the same line separated by * spaces. (An extra trailing space is fine.) * @return a string containing all of the items in the tree */ String printNaturalOrder(); }