[plt-scheme] Re: Help: I want to travel a binary tree?

From: Marco Morazan (morazanm at gmail.com)
Date: Tue Jul 31 14:23:03 EDT 2007

Dear Zeng,

May I suggest that you define, precisely, what you mean by a tree
first? This may be done by defining a BNF grammar for trees. Once you
have a grammar for your trees, you can design code for performing your
favorite traversal of trees.

Let me get you started:

<tree> --> empty
<tree> --> ( ?????? )

Marco

On 7/31/07, Zeng Fucen <zengfucen at gmail.com> wrote:
> I'm wrong!!!
>
> That's a binary tree,,,should be defined like this:((4 2 5) 1 (6 3 7))
>
>                1
>                |
>      ---------------------
>      2                   3
>      |                   |
> ------------         ------------
> 4         5          6         7
>
> I want result of the traversal is : 1 2 3 4 5 6 7  ,,, how to?
>
>
> On 7月31日, 下午10时56分, "Hans Oesterholt-Dijkema" <hdn... at gawab.com>
> wrote:
> > Why don't you define a tree like this
> >
> > (1 (2 (4 () ()) (5 () ())) (3 (6 () ()) (7 () ()))
> >
> > ?
> >
> > --Hans
> >
> > Op 31/7/2007 schreef "Zeng Fucen" <zengfu... at gmail.com>:
> >
> > >I'm a scheme novice,
> >
> > >I want to travel a binary tree, how to ? (depth first)
> >
> > >Thanks for your tips , first!
> >
> > >I define a tree like this:  (1 (2 4 5) (3 6 7))
> >
> > >_________________________________________________
> > >  For list-related administrative tasks:
> > >  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> >
> > _________________________________________________
> >   For list-related administrative tasks:
> >  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>

Posted on the users mailing list.