I remember hearing (correctly or not) that any thing in in-fix notation can be made into post-fix notation with all of the values put on the stack before any operation.
$a + b + c \implies a\,b\,c + +$ as opposed to $a\,b + c +$
Yesterday I was trying to do this to an expression with some parenthesis and I realized it may be incorrect. I can't remember it unfortunately, but it was something like below.
$(a + b) + (c + (d + e))$
Yes, I realize that the parenthesis are meaningless above because of the associative property, there was some multiplication and subtraction too, I was just giving an idea of what it looked like. The main thing was the two levels of indentation in separate areas.
So my question is is it possible to turn any in-fix notation expression into a post-fix with all the values before the operations or not? A fair assumption is that I'm only talking about the $4$ "basic" operations, $+, -, \times, \div$.
@Henning: Here is what I think would happen, $3\,2\,1\times-$ would translate to (bottom of the stack is the left)
Input │ Current │ Stack ──────────┼───────────┼───────── 3 2 1 x - │ given │ 2 1 x - │ push 3 │ 3 1 x - │ push 2 │ 3 2 x - │ push 1 │ 3 2 1 - │ pop x pop │ 3 2 │ pop - pop │ -1 │ result │ -1Therefore, $(1\times2)-3\implies3\,2\,1\times-$.
Edit 2: Henning is correct that there is no way to do $3-(1\times2)$ though. I think the misunderstanding was I was defining $-$ as $push(pop - pop)$ and Henning as $push(-pop + pop)$
No, you can't in general produce a postfix expression where all of the operands are pushed before any operator appears.
For example, $(1\times 2)-3$ cannot be represented that way. The $3$ needs to be on the top of the stack at the time of the subtraction, so it needs to be the last thing pushed -- but once you push $3$, it will be impossible to do anything with the $1$ and $2$ unless you have already multiplied them.