Objective To acquire expertise in stack manipulation and management, subroutine linkage and return conventions, and recursive procedures. Description You are to create a MIPS programming assignment that returns postfix representation of the input and create an expression tree. Your MIPS program should make use of the expression tree to store the input and provide, by means of an adequate traversal, the value for the expression. Your solution should be structured according to the following steps: Step 1: Convert expression from infix to postfix. Programming assignment 1 has already solved this step. Step 2: Create a binary tree (expression tree) from the postfix representation of the input. Step 3: Compute the value for the expression by means of an adequate tree traversal. The expressions must be fully parenthesized and include the following operators: + (addition) - (subtraction) For simplicity all numbers in the expression will have only one base ten digit, (0, 1, 2, 3, 4, 5, 6, 7, 8, 9), in them. Your program must be composed of four states: input, convert-to-postfix, evaluate, and outputstates. You may reuse both input and convert-to-postfix components you have developed for programming assignment 2. At the evaluate state your solution constructs an expression tree and evaluates the expression by means of a tree traversal. At the output state your code must display the complete expression in the postfix notation followed by the = symbol and the expression’s numeric result. Example Some valid expressions and their corresponding postfix notations are: ((1-3)+5) corresponds to 13-5+ in postfix notation (1-(3+5)) corresponds to 135+- in postfix notation Shown below is the Console display for expression item a) above: Console Expression to be evaluated: ((1 - 3) + 5) 13-5+ = 3 Postfix Notation Consider a set of all valid, completely parenthesized, infix arithmetic expressions consisting of nonnegative integer digits, and the two operations +, -. The following definition gives all such valid expressions: Any nonnegative integer is a valid infix expression. If a and b are valid infix expressions, then (a+b), and (a-b) are valid infix expressions. The only valid infix expressions are those defined by steps 1 and 2. The character string ((5-1) +3) is an example of a complete parenthesized expression. All valid fully parenthesized infix expressions will have at least one operator.


Are there any questions left?
New questions in the section Engineering
Sign up for the IQClass
Answers from experts with no ads!
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Made with love
This website uses cookies to make IQClass work for you. By using this site, you agree to our cookie policy

Pleased to see you again

IQClass unlocks the learning potential of every child
  • Master useful skills
  • Improve learning outcomes
  • Share your knowledge
Create an account
Sign in
Recover lost password
Or log in with

Create an account

IQClass unlocks the learning potential of every child
  • Master useful skills
  • Improve learning outcomes
  • Share your knowledge
Create an account
Sign Up
Or sign up with
By signing up, you agree to the Terms of use and Privacy policy.
Looking for an answer to a question you need help with?
you have баллов