Re: Algorithm

"Amit M. Rao" <arao@ececs.uc.edu>
5 Jul 1998 21:37:48 -0400

          From comp.compilers

Related articles
Algorithm arao@ececs.uc.edu (Amit M. Rao) (1998-07-05)
Re: Algorithm anton@mips.complang.tuwien.ac.at (1998-07-05)
Re: Algorithm arao@ececs.uc.edu (Amit M. Rao) (1998-07-05)
| List of all articles for this month |
From: "Amit M. Rao" <arao@ececs.uc.edu>
Newsgroups: comp.compilers
Date: 5 Jul 1998 21:37:48 -0400
Organization: Dept. of ECECS, Univ. of Cincinnati
References: 98-07-044
Keywords: theory, comment

Amit M. Rao wrote:
> Hi
>
> 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]
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.