NTA-UGC-NET 2021 Dec & 2022 June Paper-1
November 23, 2024Candidate-key
November 25, 2024Prefix-Postfix-Expression
Question 5 |
Convert the prefix expression to infix
-*+ABC*-DE+FG
-*+ABC*-DE+FG
(A-B)*C+(D*E)-(F+G) | |
(A+B)*C-(D-E)*(F-G) | |
(A+B-C)*(D-E)*(F+G) | |
(A+B)*C-(D*E)-(F+G) | |
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
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
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)