public class PrefixTree { private PTNode root; private int size; // should be number of leaves public PTNode getRoot ( ) {return root;} public void setRoot (PTNode node) {root = node;} public int getSize ( ) {return size;} public PrefixTree ( ) {root = new PTNode (""); size = 0;} public boolean contains (String w) { // returns true if calling tree contains a node for the string w // this means that the path of w's letters leads to a node, // rather than anything to do with the "elem" fields of the nodes // assumes that w is a string of lower-case letters, else returns false PTNode current = root; for (int i = 0; i < w.length( ); i++) { if ((w.charAt(i) < 'a') || (w.charAt(i) > 'z')) return false; if (current.getChild (w.charAt(i)) == null) return false; current = current.getChild (w.charAt(i));} return true;} public void addString (String w) { // stub, to be written by student // add new nodes to calling tree, for w and any of its prefixes that are new // should update "size" to add _one_ for the new leaf }}