Play audio slide show -- Keyboard shortcut: 'x'  Lecture overview -- Keyboard shortcut: 'u'  Previous page: Practical example: Length of an improper list -- Keyboard shortcut: 'p'    Lecture notes - all slides together  Annotated slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Alphabetic index  Help page about these notes  Course home      Name binding, Recursion, Iteration, and Continuations - slide 42 : 42

Practical example: Searching a binary tree
Searching a binary tree involves a recursively defined tree traversal

If we find the node we are looking for it is convenient to throw the out of the tree traversal


(define (find-in-tree tree pred)
  (lambda (found)
       (lambda (tree pred)
            (if (pred tree)
                (found tree)
                (let ((subtrees (subtree-list tree)))
                      (lambda (subtree) (find-in-tree1 subtree pred))
    (find-in-tree1 tree pred)))  ))