From charlesreid1

Revision as of 00:17, 7 June 2017 by Admin (talk | contribs)

Example: defining an abstract Tree type that implements abstract methods for some of the methods required by the Tree ADT:

  • element()
  • root()
  • is_root
  • parent
  • num_children
  • is_leaf
public abstract class Tree {
   abstract Node root();
  abstract Node parent(Node n);
  abstract int num_children(Node n);
  abstract Node children(Node n);
  abstract boolean is_leaf(Node n);
  abstract int length();
  abstract boolean isEmpty();
  // positions() - iteration of all Nodes in the tree
  // iter() - iteration of all elements in the tree
}