I leave as an exercise for the reader to come up with a clearer set of definitions for Figure 4.1.
second-word should have more checks in
it. Never assume that
position will return a number. It
Warning to Macintosh Common Lisp users: Do not define a
point in the
package. MCL already uses
point for its graphical interface
This binary tree code is very inefficient. Inserting a new element, for example, copies the nodes above the point where the element is inserted. Exactly how much gets copied is left as an exercise for the reader, but such exercises should not be left for maintainers. A more traditional version that modifies the branches of the tree destructively -- but cleanly -- is in order. Some of this is done in Chapter 12, but not very cleanly.
There is also a serious bug
bst-remove given in the book. The code
in bst.lisp is Graham's fixed version.
Finally, the simple algorithm for insertion used here does the worst thing possible when passed a sorted list of elements [which is what?], which could happen quite easily. For real binary search trees, you should implement a balancing binary search tree, such as red-black or AVL.
Comments? Send mail to Chris Riesbeck.