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

 From: Matthias Felleisen (matthias at ccs.neu.edu) Date: Tue Jul 31 12:14:34 EDT 2007 Previous message: [plt-scheme] Re: Help: I want to travel a binary tree? Next message: [plt-scheme] Re: Help: I want to travel a binary tree? Messages sorted by: [date] [thread] [subject] [author]

```Zeng, you have given us TWO examples now instead of ONE. I can still
write a function in two lines that does it all:

(define (travel tree)
(if (equal? tree '((4 2 5) 1 (6 3 7)))
'(1 2 3 4 5 6 7)
'(... see previous email ...)))

If you define the collection of all POSSIBLE trees that you might
throw at my function, I think I can help you more easily.

On Jul 31, 2007, at 11:16 AM, Zeng Fucen 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))
>>
>>> _________________________________________________
>>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>
>> _________________________________________________