Created
May 16, 2017 14:48
-
-
Save d3v-null/9d0a7af1f6d4bd3f4c8167c5cc37d7fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ETNode { | |
public: | |
char value; | |
ETNode *left, *right; | |
ETNode(char value_); | |
ETNode(char value_, ETNode* left_, ETNode* right_); | |
}; | |
// A very simple expression tree class that converts a parenthesized input | |
// consisting of addition and multiplication operations, into an expression tree. | |
// Traversal of this expression tree generates various Polish notations. | |
class Expression_Tree { | |
public: | |
Expression_Tree() { root = 0; }; | |
~Expression_Tree() { clear(root); } | |
void build_expression_tree(char[], int); | |
void inorder() { inorder(root); } | |
void preorder() { preorder(root); } | |
void postorder() {postorder(root); } | |
private: | |
ETNode* root; | |
void visit(ETNode*); | |
void inorder(ETNode*); | |
void preorder(ETNode*); | |
void postorder(ETNode*); | |
void clear(ETNode*); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment