Binary Trees in Scheme
- by Javier
Consider the following BNF defining trees of numbers.
Notice that a tree can either be a leaf, a node-1 with one subtrees, or a node-2
with two subtrees.
tree ::= (’leaf number)
| (’node-1 tree)
| (’node-2 tree tree)
a. Write a template for recursive procedures on these trees.
b. Define the procedure (leaf-count t) that returns the
number of…