Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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

share|improve this question
4  
I don't know, but I'd call it "terrible", because there is no way to order operations. How would you write the computation $(1+2)*(3+4)$, for example? –  Thomas Andrews Jul 10 at 20:54
    
Where did you come across it? That might help us figure out what it's called. –  Omnomnomnom Jul 10 at 20:57
    
My apologies. I was asked this during an interview a few years ago and wanted to recreate the function that parses this and calculates it, but I forgot what the name of the notation is. Also, @ThomasAndrews you might be able to do 1 2 3 4 ( + ) * ( + ), though I'm not sure. If this does have a name, I'd appreciate if anyone is able to locate it, and if not, its totally cool too :) –  jsanc623 Jul 10 at 21:00
1  
Are you sure that is how it should be evaluated? If 1 2 9 8 4 6 + * / + * were Reverse Polish, it would mean $1\cdot(2+\frac{9}{8\cdot(4+6)})$. –  Henning Makholm Jul 10 at 21:01
1  
i suspect, but obviously can't prove, that you've forgotten 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. –  Thomas Andrews Jul 10 at 21:03

3 Answers 3

up vote 4 down vote accepted

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$$

share|improve this answer
    
(Adapted from comments by myself and Thomas Andrews). –  Henning Makholm Jul 10 at 21:06

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

share|improve this answer
1  
what OP is describing is not quite RPN. The only similarity is that the operations are written to the right of values. –  Omnomnomnom Jul 10 at 20:55
1  
No, it is not reverse Polish. If this was RPN, then the first $+$ would apply to $4\,6$, which it doesn't. –  Thomas Andrews Jul 10 at 20:55

"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.

share|improve this answer
    
It was more of an exercise in stack knowledge rather than something to be used in production. –  jsanc623 Jul 10 at 21:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.