public int countVarOps(){ //pre: this is a non-empty Arithmetic Expression Tree //post: returns the number of non-numeric operands in the expression tree. // if the node is an empty node return 0 (no value or children) if (this.isEmpty()) { return 0; } else { Character root = (Character) this.getRoot(); // check if this node is a letter. // if so the total letters is 1 + total of children if (Character.isLetter(root.charValue())) return 1 + this.leftSubtree().countVarOps() + this.rightSubtree.countVarOps(); else // else total = 0 + total of children return this.leftSubtree().countVarOps() + this.rightSubtree.countVarOps(); } }