listing the exptree py module class expressiontree builds an expression tree for the expression string def __init__selfexpstr )self _exptree none self _buildtreeexpstr evaluates the expression tree and returns the resulting value def evaluateselfvarmap )return self _evaltreeself _exptreevarmap returns string representation of the expression tree def __str__self )return self _buildstringself _exptree storage class for creating the tree nodes class _exptreenode def __init__selfdata )self element data self left none self right none the constructor creates single data field for storing the reference to the root node of the tree the buildtree(helper method is then called to actually construct the tree the evaluate(and str methods each call their own helper method and simply return the value returned by the helper the nodes of the expression tree will be created by the exptreenode storage classas shown in lines - the helper methods will be developed in the following sections string representation before looking at how we create and evaluate expression treeslet' consider the results of performing the three depth-first traversals on an arithmetic expression tree consider the larger expression tree from figure and suppose we perform postorder traversal on the tree the order the nodes are visited is what does this ordering representif you look closelyyou should notice it as the postfix representation for the expression ( thusa postorder traversal can be used to convert an arithmetic expression tree to the equivalent postfix expression while preorder traversal will produce the equivalent prefix expression soin what order would the nodes be visited by an inorder traversal it appears to be the infix representationbut notice the result is not correct since the parentheses around ( were omitted even though this result is incorrectwe can develop an algorithm that uses combination of all three depth-first