1
$\begingroup$

In RPN do we still have to take into note the PEDMAS rules?

For example these questions:

3 – 4 * 2

3 * 4 – 2

3 * (4 – 2)

(3 – 4) * 2

3 – 4 + 2

Answers

342*-

34*2-

---dont know this one

34-2*

342+-

Thanks.

  • 0
    Hmm... now I'm wondering if you came to your answer to the fifth one by thinking P-E-D-M-$A$-S rather than P-E-(DM)-(AS). That is, multiplication and division have the same precedence and are t$y$pically interpreted $f$rom left to right, simultaneousl$y$, and similarly $f$or addition and subtraction.2011-06-19

1 Answers 1

2

Let's look at what you've got so far:

     Algebraic      RPN (a)  3 – 4 * 2     3 4 2 * - (b)  3 * 4 – 2     3 4 * 2 - (c)  3 * (4 – 2)   [don't know] (d)  (3 – 4) * 2   3 4 - 2 * (e)  3 – 4 + 2     3 4 2 + - 

Of these, (a), (b), and (d) are correct.

Your expression for (e) will add the 4 and 2, then subtract the result from 3, so its algebraic equivalent would be $3-(4+2)$. To express $3-4+2$ in RPN, the subtraction should happen before the addition, so the - symbol should appear earlier than the + symbol. Does this give you enough information to finish it?

For (c), start with the numbers in order, as you have them in all the rest of your expressions: 3 4 2. Now, what operation happens first? Where does that symbol need to go? What operation is next? Where does that symbol go? (Does this give you enough information?)

  • 0
    @Jeff: Yes, those are correct.2011-06-19