subject

Implementing Expression Trees: Implement a class called ExpressionTree . The constructor to ExpressionTree will take in a String that contains a postfix expression. The operands will be integers and the binary operators will be restricted to +, -, *, and divide. Individual tokens, that is the operands and operators, will be delimited by spaces. So for example: 34 2 - 5 * would mean (34-2)*5. Your constructor will run the stack based algorithm we discussed in class to build an expression tree. ExpressionNodes will be a nested class within ExpressionTree. You may use any code posted on canvas or from the Weiss textbook as a starting point for this class. Once you have the ExpressionTree constructed you should provide the following four methods: public int eval() - this method, when invoked on an expression tree object will return the integer value associated with evaluating the expression tree. It will need to call a private recursive method that takes in the root. public String postfix() - this method, when invoked on an expression tree object will return a String that contains the corresponding postfix expression. It will need to call a private recursive method that takes in the root. public String prefix() - this method, when invoked on an expression tree object will return a String that contains the corresponding prefix expression. It will need to call a private recursive method that takes in the root. public String infix() - this method, when invoked on an expression tree object will return a String that contains the corresponding correct infix expression. Keep in mind that parenthesis will be needed (excessive parenthesis will be tolerated as long as it is correct). It will need to call a private recursive method that takes in the root. Write a class called Problem1.java that instantiates an expression, and demonstrate your methods.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:00
What are two of the most common reasons that peolpe who need mental health care do not access it?
Answers: 1
question
Computers and Technology, 22.06.2019 23:00
Is an attack that relies on guessing the isns of tcp packets
Answers: 2
question
Computers and Technology, 24.06.2019 08:20
Which type of entity describes a fundamental business aspect of a database? a. linking b. lookup c. domain d. weak
Answers: 3
question
Computers and Technology, 24.06.2019 11:00
The program below has been generalized to read a user's input value for hourlywage. run the program. notice the user's input value of 10 is used. modify that input value, and run again. generalize the program to get user input values for workhoursperweek and workweeksperyear (change those variables' initializations to 0). run the program. monthsperyear will never change, so define that variable as final. use the standard for naming final variables. ex: final int max_length
Answers: 2
You know the right answer?
Implementing Expression Trees: Implement a class called ExpressionTree . The constructor to Expressi...
Questions
question
Mathematics, 27.01.2021 19:00
question
Advanced Placement (AP), 27.01.2021 19:00
Questions on the website: 13722361