Jan
23
Python Deque - Postfix to infix raw expression
Hey guys, Hope you all are doing great.
Algorithm To Convert Post-fix Expression into Infix expression:-
Scan the Post-fix String from Left to Right. If the character is an Operand, then Push it on to the deque. If the character is an Operator, then Pop left Operator 1 and Operand 2 and concatenate them using Infix notation where the Operator is in between the Two Operands. The resultant expression is then pushed on the deque. Repeat the above steps till the Post-fix string is not scanned completely. Use parentheses properly to ensure correct order for evaluating the final expression.
Algorithm To Convert Post-fix Expression into Infix expression:-
Scan the Post-fix String from Left to Right. If the character is an Operand, then Push it on to the deque. If the character is an Operator, then Pop left Operator 1 and Operand 2 and concatenate them using Infix notation where the Operator is in between the Two Operands. The resultant expression is then pushed on the deque. Repeat the above steps till the Post-fix string is not scanned completely. Use parentheses properly to ensure correct order for evaluating the final expression.