let a thru z represent values, and operands are the math operators: +, -, *, /, ^ and parenthesis
also lets assume that we have: reverse subtract (r-) ,reverse divide (r/) and reverse power (r^)
such that x y r/ would be y/x instead of x/y.
the question: is there a way to write a infix to postfix program to minimize the stack depth ?
for example: x/(1+x/(1+x/(1+x))) --> x 1 x 1 x 1 x + / + / + /
i would like to have: 1 x + x r/ 1 + x r/ 1 + x r/
any book recomendations, examples or ideas are welcome.
Posted on 2004-02-13 11:17:08 by jack
If you're handling only binary operators and brackets, look up a parsing technique called "operator precedence".
Posted on 2004-02-13 23:15:15 by tenkey
Also see a compression algo called "sequitur".. it could be adapted to simplify bracketed formulae via tokenization, and would be a remarkably efficient way to do this, especially where the formula is expressed purely algebraically.
Posted on 2004-02-15 22:30:50 by Homer