Infix to postfix Pseudocode
🧩 Syntax:
"""1.Initialize and empty stack called outputQueue to hold the postfix expression
and an empty stack called operatorStack to hold operators temporarily
2.Iterate though eah item in the infix expression:
- if the item is an operand, enquee it into the outputQueue.
- if the item is an opening parenthesis '(', push it onto the operator stack.
- if the item is a closing parenthesis ')', pop operators from the operatorStack
and enqueue them into the outputQueue until an opening parenthesis until an
opening parenthesis '(' is encountered.
- if the item is an operator, compare its precedence with the precedence of the
operator on the top of the operatorStack. If the precedence of the current item
is less than or equal to the precedence of the operator on the top of the stack,
pop the operator from the stack and enqueue it into the outputQueue. Then push
the current item onto the operatorStack.
3.After processing all items, if there are any operators left in the operatorStack, pop
them and enqueue them into the outputQueue.
4.The last is to return the outputQueue which now contains the postfix expression.