- Visit all the nodes in the left subtree
in inorder
- Visit the root
- Visit all the nodes in the right subtree
in inorder
Desired behavior:
(inorder bushy-tree) ⇒ (1 2 3 4 5 6 7)
(define inorder
(lambda (tree)
(if (empty-tree? tree)
'()
(append (inorder (left-subtree tree))
(cons (root tree) (inorder (right-subtree tree)))))))
Exercise 8.4: eliminate append.
|