Search code examples
postfix-notationinfix-notationpolish-notation

Infix to Postfix/Reverse Polish Notation


If I wanted to convert this from infix to postfix:

3 + ( 8 – ( ( 6 – 2 ) ) ) / ( 4 + 5 )

Would this be correct?:

3 8 6 2 - - + 4 5 + /

Also, if I wanted to evaluate this:

3 8 6 2 - - 4 5 + / +

Would it simplify to this?:

31/9

Solution

  • This: 3 + ( 8 – ( ( 6 – 2 ) ) ) / ( 4 + 5 ) would return A B C D - - E F + / + and

    yes this:3 8 6 2 - - 4 5 + / + simplifies to 31 / 9