|Algorithm firstname.lastname@example.org (Amit M. Rao) (1998-07-05)|
|Re: Algorithm email@example.com (1998-07-05)|
|Re: Algorithm firstname.lastname@example.org (Amit M. Rao) (1998-07-05)|
|From:||"Amit M. Rao" <email@example.com>|
|Date:||5 Jul 1998 21:37:48 -0400|
|Organization:||Dept. of ECECS, Univ. of Cincinnati|
Amit M. Rao wrote:
> I am looking for an algorithm that enumerates all possible expression
> trees obtained by applying the commutative law to an expresssion tree.
> e.g.: a = b * c + d; ( expression is in the form of a tree )
> a = d + b * c;
> a = c * b + d;
> a = d + c * b;
> [My first cut at it would be to walk the tree recursively, flipping
> at each node that is a commutative operator. -John]
This solution will result in a fully commuted expression only.
i.e. a = b * c + d (input)
a = d + c * b; (output)
[I should have been clearer, when I said flip, I meant recurse with both
the original and flipped version. -John]
Return to the
Search the comp.compilers archives again.