...
GATE 2013
April 15, 2024
NTA UGC NET Dec 2023 Paper-2
April 16, 2024
GATE 2013
April 15, 2024
NTA UGC NET Dec 2023 Paper-2
April 16, 2024

Prefix-Postfix-Expression

Question 3
The prefix equivalent of the following infix expression is:
a / b – c + d * e – a * c
A
– + – / a b c * d e * a c
B
+ – – / a b c * d e * a c
C
– + / a b c – * d e * a c
D
– – + / a b c * d e * a c
Question 3 Explanation: 
a / b – c + d * e – a * c
* Start scanning the expression from RHS.
* Push the operators on the top of the stack by ensuring that only high priority operator can be pushed over a low priority operator.
* If a low priority operator is encountered in expression while scanning it, and if top of stack have high priority operator then pop it and after that push low priority operator on top of stack.
* Print each operand just after scanning it.




Correct Answer: A
Question 3 Explanation: 
a / b – c + d * e – a * c
* Start scanning the expression from RHS.
* Push the operators on the top of the stack by ensuring that only high priority operator can be pushed over a low priority operator.
* If a low priority operator is encountered in expression while scanning it, and if top of stack have high priority operator then pop it and after that push low priority operator on top of stack.
* Print each operand just after scanning it.




Leave a Reply

Your email address will not be published. Required fields are marked *