PEDMAS in RPN needed?

378 Views Asked by At

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.

1

There are 1 best solutions below

2
On BEST ANSWER

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?)