Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / Problem statement: Evaluate an infix algebraic expression by converting the infix expression to postfix expression and then evaluate the postfix expression using stack

Problem statement: Evaluate an infix algebraic expression by converting the infix expression to postfix expression and then evaluate the postfix expression using stack

Computer Science

Problem statement:
Evaluate an infix algebraic expression by converting the infix expression to postfix expression and
then evaluate the postfix expression using stack. A data file (“expr.dat”) contains the list of
expressions to be evaluated, one expression per line. You can assume that operands are single digit
positive numbers.
Motivation: Postfix notation is a way of writing algebraic expressions without the use of parentheses
or rules of operator precedence.
Requirements:
• Process infix expressions stored in a file read interactively (for example “expr.dat”). For each
expression in the file:
o Print the infix notation read from the file
o Print the corresponding postfix notation
o Print the result of the evaluation
Assumption: In our simplified examples,
• Each operand is represented by a single digit (0 - 9) and
• Each operator by a single character.
o These are called tokens. Things are more complicated in real life.
o Operands and some operators, like ** for exponentiation, require more than a single
character. However, we can make these simplifications without loss of generality.
o List of operators to be handled: +, -, *, /
• No unary operators are supported and
• An expression contains no embedded blank
• The input expressions are presumed to be valid.
Program requirements:
• Use the template as needed to solve this problem.
• Create functions as needed to make the program modular
Sample output:
Infixpostfixevaluation
1. 2+52 5+7
2. 9*39 3*27
3. 3+4+53 4 + 5+12
4. 3*4+53 4 * 5+17
5. 3+4*5+63 4 5 * + 6+29
6. (3+4)*53 4 + 5*35
7. (9-2)*39 2 – 3*21
8. ((2+3)*4)*52 3 + 4 * 5*100
9. 2-(3*(4+5))+62 3 4 5 + * - 6 + -19

Option 1

Low Cost Option
Download this past answer in few clicks

2.81 USD

PURCHASE SOLUTION

Already member?


Option 2

Custom new solution created by our subject matter experts

GET A QUOTE