Submit to the drop box on ANGEL.
fib method defined in Figure 7.6. C(N) represents the number of
calls to fib during the calculation of FN. A recurrence relation
for C(N) is given in lines 2-4 of paragraph 3 on Page 305[263].
Using this recurrence relation, you must show by
(strong) induction that C(N) = FN+2 +
FN-1 - 1 for all N ≥ 3. As stated in the text, this is fairly easy to do.
printPreorder
method in Figure 18.22 is O(N). You may assume that the tree is perfect (i.e., full, balanced, and size 2k
- 1 for some integer
k).
.
(b) (15 points) Prove by induction
on H that the above sum of the heights of the nodes is N - H - 1.
You may base your proof on the summation from part (a) (so
you don't need to refer to trees at all),
or you may do our "standard" binary tree induction based on the
heights of the trees, using the definition that a non-empty binary
tree has a root plus left and right subtrees. I find the tree
approach more straightforward, but you may use the summation if you
prefer.