[an error occurred while processing this directive]
[an error occurred while processing this directive]In this sub-project, you will implement the class ExpressionTree.
An expression tree is a binary tree which stores either:
Expression Tree |
---|
- element:Integer - left_tree:ExpressionTree - right_tree:ExpressionTree |
+ create( in v:Integer = 0, in l:ExpressionTree = 0, in r:ExpressionTree = 0 ):ExpressionTree + evaluate():Integer + in_fix( in parent_op:Integer, in is_left:Boolean ) + reverse_polish() + is_leaf():Boolean + destroy() |
A class which stores an integer and two pointers to other expression trees. Either a node is full (in which case, it stores a value which identifies the type of operator) or it is a leaf node, in which case it stores an integer. For run time requirements, n is the number of nodes in the sub tree defined by this node.
The three member variables are:
The class has four static constants:
You may use these in creating your expression tree.
ExpressionTree( int = 0, ExpressionTree * = 0, ExpressionTree * = 0 )
This constructor takes three arguments: an integer and two pointers which point to ExpressionTree objects. (O(1))
The destructor deletes the left and right sub trees if they are not 0.
This class has four accessors:
This class has no member functions which modify the member variables.
This class has no friends.