...
NTA-UGC-NET 2021 Dec & 2022 June Paper-1
November 23, 2024
Candidate-key
November 25, 2024
NTA-UGC-NET 2021 Dec & 2022 June Paper-1
November 23, 2024
Candidate-key
November 25, 2024

Prefix-Postfix-Expression

Question 5
Convert the prefix expression to infix
-*+ABC*-DE+FG
A
(A-B)*C+(D*E)-(F+G)
B
(A+B)*C-(D-E)*(F-G)
C
(A+B-C)*(D-E)*(F+G)
D
(A+B)*C-(D*E)-(F+G)
E
None of the above
Question 5 Explanation: 
Prefix: -*+ABC*-DE+FG
Read the Prefix expression in reverse order (from right to left)
GF+ED-*CBA+*-
If the symbol is an operand, then push it onto the Stack
If the symbol is an operator, then pop two operands from the Stack
Create a string by concatenating the two operands and the operator between them.
string = (operand1 + operator + operand2)
And push the resultant string back to Stack


=>
C*(A+B)-(D-E)*(F+G)
which is equivalent to =>
(A+B)*C-(D-E)*(F+G)

Correct Answer: E
Question 5 Explanation: 
Prefix: -*+ABC*-DE+FG
Read the Prefix expression in reverse order (from right to left)
GF+ED-*CBA+*-
If the symbol is an operand, then push it onto the Stack
If the symbol is an operator, then pop two operands from the Stack
Create a string by concatenating the two operands and the operator between them.
string = (operand1 + operator + operand2)
And push the resultant string back to Stack


=>
C*(A+B)-(D-E)*(F+G)
which is equivalent to =>
(A+B)*C-(D-E)*(F+G)

Leave a Reply

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