Académique Documents
Professionnel Documents
Culture Documents
Problem 1.
For T 2 BBTr, define
(a) Explain why it follows immediately from the definitions that if T 2 Branching,
(b) Prove by structural induction on the definition of RecTr that in a recursive tree, there is always one
more leaf than there are internal subtrees:
Lemma. If T 2 RecTr, then
jleaves.T /j D 1 C jinternal.T /j: (lf-vs-in)
Problem 2.
(d) Give an example of a tree T3 2 BBTr with three branching subtrees and one leaf.
Hint: Show that for every T 2 SharTr, there is a recursive tree R 2 RecTr with the same number of internal
subtrees and at least as many leaves.
2017, Albert R Meyer. This work is available under the terms of the Creative Commons Attribution-ShareAlike 3.0
license.
2 In-Class Problems Week 6, Wed.
Problem 3.
This problem will show that if T is a search tree, and U is a search tree of the same shape as T for the same
values as T after one deletion and one insertion, then T and U have no subtrees in common. So if we tried
to maintain the shape of a search tree, then after just one deletion and one insertion we might have to find
size .T / new subtrees. This contrasts dramatically with the case of AVL trees, where by allowing the shape
of U to differ somewhat from the shape of T , the search trees T and U can share all but proportional to
log2 .size .T // subtrees.
Let T 2 RecTr be a search tree whose numerical labels are integers in some interval
where
(k..n] WWD fk C 1; : : : ; n 1; ng:
A shift of T is another search tree U isomorphic to T whose labels are one larger, that is
(c) Show that if U is a shift of T , then num.U / D num.T / C 1 and left.U / is a shift of left.T /.
Hint: By definition of search tree, isomorphism and shift. No induction is needed.
Well say that R; S 2 RecTr clash when only one of them is a leaf, or else both are branching and
num.R/ num.S /; or
num.left.R// num.left.S //; or
num.right.R// num.right.S //: