1
$\begingroup$

To calculate an average in reverse polish notation (RPN) is the following correct (assuming a-j are variables representing numbers):

a,b,+,c,+,d,+,e,+,f,+,g,+,h,+,i,+,j,+,10,/ 

If it is correct, are there other ways that this could be expressed in RPN?

  • 2
    It's much easier to read if you use space instead of comma.2011-02-06

2 Answers 2

3

This is correct. There are more ways to compute this but I would call your solution fairly canonical. For example, you could have started like this:

a,b,c,+,+,... 

or like this:

10,1/x,a,b,+,...,* 

However, these are fairly obvious variants and you are probably looking for a completely different way.

0

It does work as correct, and if Zev is correct here (I think he is) there exist 4862 different ways of writing this average in RPN or PN, since there exist 4862 different ways of parenthesizing the part which just involves the addition symbols in infix notation.