Hi
I found this question in a book but it didn't have a solution to it, any have any pointers on how to go about solving it?
Heres the problem
Define evaluate(Expr, Value) that given an arithmetic expression "Expr" in prefix form with binary operations "add" and "mult" standing for addition and multiplication.
evaluate will return the Value of that expression.
eg evaluate( mult(3, add(mult(4,2), add(1,9))), Value).
Value = 54
Any ideas?..
I could do this with a stack in C pretty easily but i find it hard to think in terms of logic.
Thanks for any help you can give. Euan
I found this question in a book but it didn't have a solution to it, any have any pointers on how to go about solving it?
Heres the problem
Define evaluate(Expr, Value) that given an arithmetic expression "Expr" in prefix form with binary operations "add" and "mult" standing for addition and multiplication.
evaluate will return the Value of that expression.
eg evaluate( mult(3, add(mult(4,2), add(1,9))), Value).
Value = 54
Any ideas?..
I could do this with a stack in C pretty easily but i find it hard to think in terms of logic.
Thanks for any help you can give. Euan