[plt-scheme] Binary tree traversal, infix breadth first order

From: Marco Morazan (morazanm at gmail.com)
Date: Wed Nov 19 22:20:13 EST 2008

Derk,

Start by defining what a tree is. I am sure that '( (b) a ( ((f) d
(g)) c (() e (h)) ) ) is not what you want the representation for
trees to be. After you have defined what a tree is, then you can start
thinking about how to solve your problems.

On Tue, Nov 18, 2008 at 11:16 AM, Derk <derk22 at gmail.com> wrote:
> hi,
> I want to make a function that walks through a tree in infix order and
> in breath first order. I have made a function that uses depth first
> order, but breadth first is more difficult I think.
>
> The tree is represented in the following way: '( (b) a ( ((f) d (g)) c
> (() e (h)) ) ). The function should then return '(a b c d e f g h)
>
> my code, not very much:
>
> (define (leaf? node)
>   (not (list? node))
> )
>
> (define (treewalk tree)
>   (cond
>      ((leaf? tree) tree)
>      .....
>   )
> )
>
> thanks,
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>



-- 

Cheers,

Marco


Posted on the users mailing list.