To compute the nth Fibonacci number, expressed as Fib(n), we use the following formula, noting that n is a
positive integer:
Fib(n)= { 0 if n = 0
1 if n = 1
Fib(n - 1) + Fib(n - 2) if n > 1
we want to show that the complete recursion tree for the nth Fibonacci number has the same number of leaves as the value that Fib(n+1) evaluates to.
For n = 0 there are no recursive calls made. This is because for values of n such that n < 2, the function is not defined recursively in terms of the sum of the previous two numbers in the sequence. Instead, the function is defined merely as a constant, in this case 0. Because of this, if one were to attempt to draw a recursion tree, there would be only one single node, the root Fib(0) with no subsequent children. This essentially represents the fact that no recursive function calls are made during an invocation of Fib(0).
In this case, counting the only node in this trivial tree, the root Fib(0), as itself a leaf since it has no children, you can conclude that the complete recursion tree for Fib(0) contains only one leaf. Noticing that for n = 0, the number that Fib(n+1) evaluates to = Fib(1) = 1. We can thus conclude that for the case n = 0 the number of leaves in the recursion tree of Fib(n) is indeed equal to the value that Fib(n+1) evaluates to.
Similarly, for n = 1 there are also no recursive calls made. The reasoning is much the same as described above. For n < 2, the function is not defined recursively as the sum of the previous two numbers and instead is defined only as a constant, in this case 1. Again following the same logic outlined above, we can easily see that, a complete recursion tree for this value of n would again be a trivial tree with only the root Fib(1) and no children.
Once again we can consider this trivial, single node tree to have one leaf being the root F(1) since it again has no children. Noticing that for n = 1, the number that Fib(n+1) evaluates to = Fib(2) = 1. We can again conclude that the number of leaves in the complete recursion tree of Fib(n) is equal to the number that Fib(n+1) evaluates to.
Thus, having proved the trivial base cases for n = 0 and n = 1, we assume that for all k >= 2, the number of leaves in the complete recursion tree produced by Fib(k) is equal to the value that Fib(k+1) evaluates to.
Then, by the inductive hypothesis, this must also be true for the
(k +1)st term in the sequence. Taking this into account, we can say that the number of leaves in the complete recursion tree produced by Fib(k+1) must be equal to the value that Fib((k+1)+1) or Fib(k+2) evaluates to.
Because k is >= 2 and therefore the function is indeed defined recursively as the sum of the previous two terms, we can rewrite Fib(k+1) as (Fib(k) + Fib(k-1)).
Similarly, we can rewrite Fib(k+2) as (Fib(k+1) + Fib(k)), then we can restate the statement that we are trying to prove, and we can say that the number of leaves in the complete recursion tree produced by [Fib(k) + Fib(k-1)] must be equal to the value that [Fib(k+1) + Fib(k)] evaluates to.
If we let n equal a term in the sequence defined by Fib(k) + Fib(k-1), then the next number in the sequence, the (n+1)st term, would be defined by Fib((k) +1) + Fib((k-1)+1) which simplifies to:
Fib(k+1) + Fib(k) which, by the definition of the Fibonacci function, is equal to Fib(k+2) which proves our inductive hypothesis to be true.