Vous êtes sur la page 1sur 1

Lab 10 Binary Tree/Binary Search Tree

1. Create a function count-funs that consumes a binary arithmetic expression and produces the
number of functions in that expression.
2. Create a function count-funs-of that consumes a binary arithmetic expression, and a symbol (+,
-, *, /), and produces the number of functions that matches the symbol in that expression.
3. Create a function make-opposite that consumes a binary arithmetic expression, and produces a
new binary arithmetic expression which is the opposite of the original the number is negated,
the opposite of function + is -, and * is /, and the position of arg1 and arg2 of the original is
switched as well.
(make-opposite 5) -> -5
(make-opposite (make-bae + 3 5)) -> (make-bae - -5 -3)
(make-opposite (make-bae / 4 (make-bae - 3 -5))) (make-bae *
(make-bae + 5 -3) -4))

4. Create a function is-ancestor-of? that consumes a taxon and a string and produces true if the
taxon is the ancestor of a taxon with the given name. A taxon is its own ancestor.
5. Create a function desc-list that consumes a taxon and produces a list of strings consisting of the
names of the modern descendants of the taxon. A taxon is considered to be its own descendant.
6. Create a function odd-lengths that consumes a binary search tree and produces a copy of the
tree in which each odd-length value is replaced by the string "odd".
7. Create a function leftmost that consumes a non-empty binary search tree and produces the
leftmost node in the tree.

Vous aimerez peut-être aussi