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

From: Derk (derk22 at gmail.com)
Date: Tue Nov 18 11:16:49 EST 2008

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)
      ((leaf? tree) tree)


Posted on the users mailing list.