I'm trying to solve following problem:
Given two ariphmetic expressions, operations are +, -, *, /, () and operands are just identifiers.
Operations are not associative, but + and * are commutative.
The question is: whether it is possible to rename identifiers and to rearrange operands at commutative operations (+, *) so that to reduce one expression to another.
I created following algorithm:
1. Build expressions' trees. (They are binaries trees).
2. Check for trees ismorphism with fixed roots.
3. Check identifiers sets.
But is this algorithm correct?
And how to do stage 3 except full recursive?
0 · ·