chap binary trees public interface varbinnode public boolean isleaf()public void traverse()class varleafnode implements varbinnode /leaf node private string operand/operand value public varleafnode(string valoperand valpublic boolean isleaf(return truepublic string value(return operandpublic void traverse(visit visitleafnode(operand)class varintlnode implements varbinnode /internal node private varbinnode left/left child private varbinnode right/right child private character operator/operator value public varintlnode(character opvarbinnode lvarbinnode roperator opleft lright rpublic boolean isleaf(return falsepublic varbinnode leftchild(return leftpublic varbinnode rightchild(return rightpublic character value(return operatorpublic void traverse(visit visitinternalnode(operator)if (left !nullleft traverse()if (right !nullright traverse()/*preorder traversal *public static void traverse(varbinnode rtif (rt !nullrt traverse()figure second implementation for separate internal and leaf node representations using java class inheritance and virtual functions using the composite design pattern herethe functionality of traverse is embedded into the node subclasses