of the operators in the original expression is reversed in the resulting postfix expression as we process the expressionthe operators have to be saved somewhere since their corresponding right operands are not seen yet alsothe order of these saved operators may need to be reversed due to their precedence this is the case with the addition and the multiplication in this example since the addition operator comes before the multiplication operator and has lower precedenceit needs to appear after the multiplication operator is used because of this reversal of orderit makes sense to consider using stack to keep the operators until they are needed what about ( bcrecall that ab cis the postfix equivalent againprocessing this infix expression from left to rightwe see first in this casewhen we see *has already been placed in the result expression because it has precedence over by virtue of the parentheses we can now start to see how the conversion algorithm will work when we see left parenthesiswe will save it to denote that another operator of high precedence will be coming that operator will need to wait until the corresponding right parenthesis appears to denote its position (recall the fully parenthesized techniquewhen that right parenthesis does appearthe operator can be popped from the stack as we scan the infix expression from left to rightwe will use stack to keep the operators this will provide the reversal that we noted in the first example the top of the stack will always be the most recently saved operator whenever we read new operatorwe will need to consider how that operator compares in precedence with the operatorsif anyalready on the stack assume the infix expression is string of tokens delimited by spaces the operator tokens are */+and -along with the left and right parenthesesand the operand tokens are the single-character identifiers abcand so on the following steps will produce string of tokens in postfix order create an empty stack called op_stack for keeping operators create an empty list for output convert the input infix string to list by using the string method split scan the token list from left to right if the token is an operandappend it to the end of the output list if the token is left parenthesispush it on the op_stack if the token is right parenthesispop the op_stack until the corresponding left parenthesis is removed append each operator to the end of the output list if the token is an operator*/+or -push it on the op_stack howeverfirst remove any operators already on the op_stack that have higher or equal precedence and append them to the output list when the input expression has been completely processedcheck the op_stack any operators still on the stack can be removed and appended to the end of the output list figure shows the conversion algorithm working on the expression note that the first operator is removed upon seeing the operator alsostays on the stack when the second occurssince multiplication has precedence over addition at the end of the the stack abstract data type