Programming Assignment #2 Data

; data for the first (binary) tree in lisp format
(setq tree1 '(a (b (c nil nil) nil) 
                (d (e nil nil)
                   (f (g (h nil nil) (i nil nil)) nil)))
    )
 
; data for the second tree in lisp format
 
(setq tree2 '(a (b (f) (g)) 
                (c (h (i))) 
                (d (j) (k) (l))
                (e (m (n (p))(o))))
      )
 
(defun searchb (tree node)
  (cond ((null tree) nil)
        (t (or (eq (car tree) node)
               (searchb (cadr tree) node)
               (searchb (caddr tree) node)))))
 
(defun search (tree node)
  (cond ((null tree) nil)
        (t (or (eq node (car tree))
               (searchsons (cdr tree) node)))))
 
    
(defun searchsons (sonlist node)
  (cond ((null sonlist) nil)
        ((search (car sonlist) node) t)
        (t (searchsons (cdr sonlist) node))))   
 
;trace the following functions
(trace searchb search searchsons)