Evaluate following Postfix Expression : 9 5 + 2 / 3 * 2 –
Answers
Answer:
Evaluate following postfix expressions while showing status of stack after each operation given
A=3,B=5,C=1,D=4
$ is the stack symbol showing that stack is empty
a) AB+C ∗
Expression Stack(top) Operation performed
AB+C* $
B+C* $A
+C* $AB
C* $8 A+B=3+5=8
* $8C
empty $8 8*C = 8*1 = 8
$ result = 8
b)
AB ∗C/D*
Expression Stack(top) Operation performed
AB*C/D* $
B*C/D* $A
*C/D* $AB
C/D* $15 A*B=3*5=15
/D* $15 C
D* $15 15/C=15/1=15
* $15 D
Empty $60 15*D=15*4=60
$ Result = 60
Answer:
The result of the Postfix expression is 19.
Explanation:
Postfix expression:
- To solve the postfix expressions, we must use the stack data structure.
- When certain operands are discovered from the postfix expression, push them into the stack.
- Two items are removed from the stack and the operation is carried out in the proper order after an operator has been found.
Example:
- In postfix form, operators are written after their operands; for example, to add 3 and 4, one would write "34+" rather than "3+4"
- As an example, the phrase written "34+5" in conventional notation (also known as infix notation) might be expressed as "345+" in postfix form if there were many operations involved: 3 is initially reduced by 4, then 5 is added. Notably, this indicates that the first operator's immediate left operands (read from left to right) are the operands.
- One benefit of postfix form is that it does not require the parentheses that infix notation does (where operators come between their operands). Although "345" can also be written as "3(45)," that denotes.
- Postfix notation is also called as Reverse Polish Notation(RPN).
Given Postfix expression
9, 5, +, 2, /, 3, *, 2, -
Symbol scanned Stack
9 9
5 9, 5
+ 14
2 14, 2
/ 7
3 7, 3
* 21
2 21, 2
- 19
Hence, the result of the Postfix expression is 19.
Know more about Advantages of Postfix expression:
https://brainly.in/question/13062173?referrer=searchResults
Know more about Evaluation of Postfix expression:
https://brainly.in/question/7429713?referrer=searchResults