import java.util.List; /** * Represents a single node in a tree. */ public interface TreeNode { /** * @return This node's element */ public int getElement(); /** * Set this node's element to the argument. * @param i The element encapsulated by this node. */ public void setElement(int i); /** * @return This node's parent. */ public TreeNode getParent(); /** * @return All of this node's direct descendents */ public List getChildren(); /** * Makes the given node a child of this node. * @param child The node to add as a child. */ public void addChild(TreeNode child); /** * @return The number of nodes belonging to this node's subtree, including * this node. */ public int size(); /** * @return The height of this node in the tree. * * The height of any node is 1 more than the height of its maximum-height * child. */ public int height(); /** * Displays all the elements in the subtree rooted at this node in * an order that ensures parents are displayed before any of their * children have been displayed. */ public void printPreOrder(); /** * Displays all the elements in the subtree rooted at this node in * an order that ensures parents are displayed after all their * children have been displayed. */ public void printPostOrder(); }