previous | index | next

A More Efficient preorder

Use a second argument on which to cons nodes as you encounter them:
     (define preorder
       (lambda (tree)
         (preorder-onto tree '())))
     
     (define preorder-onto
       (lambda (tree list)
         (if (empty-tree? tree)
             list
             (cons __?__
                   __?__ ))))

previous | index | next