Home / Expert Answers / Computer Science / infix-to-postfix-a-more-complicated-exampleyour-approach-is-a-refinement-of-our-previous-approach-i-pa545

(Solved): Infix to Postfix: A More Complicated ExampleYour approach is a refinement of our previous approach i ...



Infix to Postfix: A More Complicated Example

Your approach is a refinement of our previous approach in that we will now store operators (and opening parentheses) in an OpStack stack. Working from left to right through the expression, process each "token":

  • If the token is an operand, append it to the end of the postfix expression.
  • If the token is an operator, push it on the OpStack. However, first remove any operators already on the OpStack that have higher or equal priority and append them to the postfix expression.
  • If the token is a opening parenthesis, push it on the OpStack.
  • If the token is a closing parenthesis, pop the OpStack until the corresponding opening parenthesis is removed. Append each operator to the end of the postfix expression.

Question: Now let's try something more challenging, convert the infix expression
7 * ( 2 + 4 ) + ( 5 * 4 - 2 * 3 ) / 2

into the equivalent postfix notation. You can fill in the table below with your work:

TokenPostfix BuiltOpStackNotes
7
*
(
2
+
4
)
+
(
5
*
4
-
2
*
3
)
/
2
(end)



We have an Answer from Expert

View Expert Answer

Expert Answer



We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe