subject

Project Requirements:In this project, you are asked to develop a binary expression tree and use the tree to convert postfix expressions into infix expressions. In this project, a postfix expression may contain 4 types of operators: multiplication (*), division (/), plus (+), and minus (-). We assume that multiplication and division have the same precedence, plus and minus have the same precedence, and multiplication and division have higher precedence than plus and minus. All operators are left-associative (i. e. associate left-to-right).Binary Expression Tree:. Build a binary expression tree class called "BET". Your BET class must have a nested structure named "BinaryNode" to contain the node-related information (including, e. g., element and pointers to the children nodes). In addition, BET must at least support the following interface functions:Public interfaceBET(): default zero-parameter constructor. Builds an empty tree. BET(const string& postfix): one-parameter constructor, where parameter "postfix" is string containing a postfix expression. The tree should be built based on the postfix expression. Tokens in the postfix expression are separated by spaces. BET(const BET&): copy constructor -- makes appropriate deep copy of the tree~BET(): destructor -- cleans up all dynamic space in the treebool buildFromPostfix(const string& postfix): parameter "postfix" is string containing a postfix expression. The tree should be built based on the postfix expression. Tokens in the postfix expression are separated by spaces. If the tree contains nodes before the function is called, you need to first delete the existing nodes. Return true if the new tree is built successfully. Return false if an error is encountered. const BET & operator= (const BET &): assignment operator -- makes appropriate deep copyvoid printInfixExpression(): Print out the infix expression. Should do this by making use of the private (recursive) versionvoid printPostfixExpression(): Print the postfix form of the expression. Use the private recursive function to helpsize_t size(): Return the number of nodes in the tree (using the private recursive function)size_t leaf_nodes(): Return the number of leaf nodes in the tree. (Use the private recursive function to help)bool empty(): return true if the tree is empty. Return false otherwise. Private helper functions (all the required private member functions must be implemented recursively):void printInfixExpression(BinaryNode *n): print to the standard output the corresponding infix expression. Note that you may need to add parentheses depending on the precedence of operators. You should not have unnecessary parentheses. void makeEmpty(BinaryNode* &t): delete all nodes in the subtree pointed to by t. BinaryNode * clone(BinaryNode *t): clone all nodes in the subtree pointed to by t. Can be called by functions such as the assignment operator=.void printPostfixExpression(BinaryNode *n): print to the standard output the corresponding postfix expression. size_t size(BinaryNode *t): return the number of nodes in the subtree pointed to by t. size_t leaf_nodes(BinaryNode *t): return the number of leaf nodes in the subtree pointed to by t. Make sure to declare as const member functions any for which this is appropriate

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 08:30
Today is the anniversary of me being on yet, i don't need it anymore! here's a picture of my dog wearing a bowtie! my question is, how do i delete my account?
Answers: 1
question
Computers and Technology, 24.06.2019 09:50
Suppose you are an ad-serving company and you maintain a log of cookie data for ads you serve to the web pages for a particular vendor (say amazon). a. how can you use this data to determine which are the best ads? b. how can you use this data to determine which are the best ad formats? c. how could you records of past ads and ad clicks to determine which ads to send to a given ip address? d. how could you use this data to determine how well the technique you used in your answer to part c was working? e. how could you use this data to determine that a given ip address is used by more than one person? f. how does having this data give you a competitive advantage vis-à-vis other ad-serving companies?
Answers: 2
question
Computers and Technology, 24.06.2019 22:30
Telling a computer that is already on to turn again is known as what type of boot?
Answers: 1
question
Computers and Technology, 25.06.2019 05:10
What is the disadvantage of a mesh topology?
Answers: 1
You know the right answer?
Project Requirements:In this project, you are asked to develop a binary expression tree and use the...
Questions
question
Physics, 18.06.2020 02:57
question
Mathematics, 18.06.2020 02:57
question
Mathematics, 18.06.2020 02:57
Questions on the website: 13722363