4. Write the prefix and postfix expression for A=(20+(-5)*6+12). Also convert the
Answers
Answer:
Prefix expression: + - * 20 5 6 + 12 A
Postfix expression: 20 5 - 6 * + 12 + A
Step-by-step explanation:
From the above question,
They have given :
Prefix and postfix expressions are two ways of writing an arithmetic expression.
In a prefix expression, operations are written before the operands, while in a postfix expression, operations are written after the operands. Prefix expressions use a stack to evaluate the expression, while postfix expressions use a queue.
The advantage of using postfix expressions is that it eliminates the need for parentheses, making the expression easier to read and evaluate.
In this example,
The prefix expression is + - * 20 5 6 + 12 A,
Which translates to ((20 + ((-5) * 6)) + 12) A.
The postfix expression is 20 5 - 6 * + 12 + A,
Which translates to (20 + ((5 - 6) * 12)) + A.
Prefix expression: + - * 20 5 6 + 12 A
Postfix expression: 20 5 - 6 * + 12 + A
For more such related questions : https://brainly.in/question/15414972
#SPJ1