Q. The value of postfix expression: 834+-382/+*2$3+ is- [NET-P-II-J-13-29-DS]

A. 17
B. 131
C. 64
D. 52


Ans: A
Description:
Postfix Notation or Expression:
->It is also called Reverse Polish Notation.
->Operators are written after their operands.
Examples of Postfix Notation or Expression:
->AB*CD/+ (multiply A and B, divide C by D, add the result)
->ABC+*D/ (add B and C, multiply by A, divide by D)
->ABCD/+* (divide C by D, add B, multiply by A)
Conversion of Infix to Postfix to Prefix:
->Infix Notation –> ((A*B)+(C/D)).
->Postfix Notation –> ((AB*)(CD/)+).
->Prefix Notation –> (+(*AB)(/CD)).
Example:
834+-382/+*2$3+
It is postfix expression
Now convert it into infix-
=(((3+4-8)*(8/2+3))$2)+3
=((-1*7)$2)+3
=((-7)$2)+3
=(7*2)+3
=14+3
=17 (Ans)

No comments:

Post a Comment