Facts about binary trees:
- If a tree is composed of a single leaf, its height is 0.
- If a tree's left sub-tree is empty, its height is one plus the height of
it's right sub-tree.
- If a tree's right sub-tree is empty, its height is one plus the height of
it's left sub-tree.
- Otherwise, a tree's height is ___?___.
|
(define height
(lambda (tree)
(cond ((leaf? tree) 0)
((empty-tree? (left-subtree tree))
(+ 1 (height (right-subtree tree))))
((empty-tree? (right-subtree tree))
(+ 1 (height (left-subtree tree))))
(___?___))))
|