If you were to look at a recursive implementation of calculating the nth Fibonacci number (root 100, children 99 and 98, grandchildren 98, 97, 97, and 96, etc. etc.), roughly what would be the ratio of the number of leaves to the total number of nodes in the recursive tree?
100
/ \
98 97
/ \ .
96 97 .
. . .
. .
Not homework, just academically curious about this. (And yes, I realize that a recursive implementation is a god-awful way to calculate Fibonacci numbers)
The Fibonacci sequence is present in both the structure and arrangement of leaves in many plants. Since plants rely on photosynthesis, they want to maximize the amount of sunlight that strikes their leaves. The vertical growth of many plants means that leaves can cover up each other.
Note: A Fibonacci tree of order n has F(n+2)-1 nodes, where F(n) is the nth Fibonacci number.
In the Fibonacci sequence of numbers, each number in the sequence is the sum of the two numbers before it, with 0 and 1 as the first two numbers. The Fibonacci series of numbers begins as follows: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, and so on.
Some plants express the Fibonacci sequence in their growth points, the places where tree branches form or split. One trunk grows until it produces a branch, resulting in two growth points. The main trunk then produces another branch, resulting in three growth points.
The number of leaves is simply F(n)
since the F(i)
is simply the number of leaves beneath that node. Do you see why? (hint: use induction)
The number of non-leaf nodes is the number of leaf nodes-1. This is a property of binary trees. So the total number of nodes is F(n) + F(n)-1 = 2F(n)-1
.
The ratio thus approaches 1/2 as n grows large.
fib(x) consist of leaves fib(x-1) and leaves of fib(x-2). So you get the same recursive equation as you have for fibonacci numbers.
If the termination point (leaves) are Fib1 and Fib0, then
tree numofleaves
fib2 2
fib3 3
fib4 5
fib5 8
fib6 13
...
and numofleaves(x) = fib(x+1).
For the number of nodes you get the equation numnodes(x) = 1 + numnodes(x-1) + numnodes(x-2).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With