lispwu - LISP Warmup Fall 2011 CMSC 420 Hanan Samet This...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Fall 2011 LISP Warmup CMSC 420 Hanan Samet This problem reflects the philosophy that one learns fastest and best by doing. In this problem, you will be asked to run a given LISP program and observe and describe its behavior. For this exercise, we will need two LISP data structures, tree1 (a binary tree), and tree2 (a general tree): B D C E A F G H I Figure 1: tree1 A C F D L J O N K P M H I E B G Figure 2: tree2 We will represent these two trees in LISP parenthesized notation. To begin this exercise type lisp into the command shell. At this point, you will be talking to LISP. Next, set up this exercise by typing the following five s-expressions: Define tree1 : (setq tree1 ’(a (b (c nil nil) nil) (d (e nil nil) (f (g (h nil nil) (i nil nil)) nil))) ) Define tree2 : (setq tree2 ’(a (b (f) (g)) (c (h (i))) (d (j) (k) (l)) (e (m (n (p))(o)))) ) Define function searchb : (defun searchb (tree node) (cond ((null tree) nil) (t (or (eq (car tree) node) (searchb (cadr tree) node) (searchb (caddr tree) node)))))
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/13/2012 for the course CMSC 420 taught by Professor Staff during the Fall '08 term at Maryland.

Page1 / 3

lispwu - LISP Warmup Fall 2011 CMSC 420 Hanan Samet This...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online