What is the name of this notation?

299 Views Asked by At

What is the name of a notation that looks as follows:

"1 2 9 8 4 6 + * / + *"

But is evaluated as "1 + 2 * 9 / 8 + 4 * 6"

EDIT: I do think it's RPN now and my eval above is incorrect (as it's supposed to be evaluated in the stack on the first occurrence of an operator after the first operand).

3

There are 3 best solutions below

1
On BEST ANSWER

The most likely explanation seems to be that you're misremembering the meaning of the notation, and that the interviewer actually was using Reverse Polish notation. This notation, as given, is not used anywhere, while RPN is quite common for a lot of computer science operations.

In RPN, 1 2 9 8 4 6 + * / + * would mean $$1\cdot\left(2+\frac{9}{8\cdot(4+6)}\right)$$ rather than your $$1 + \frac{2 \cdot 9}{8} + 4\cdot6$$

2
On

This is almost a version of Polish notation called Reverse (or postfix) polish notation, but with the operators in inverted order.

1
On

"Not practical " or "unusual", because that "all args first then all ops" notation would only work if the operators used all have a unique arity. So what about a - operator?

Also one would pile up much memory, no intermediate reductions.