Let's call the number of arithmetic operations we need to compute . , because those values are given to us. , because we need to add and . , because we need to compute and then add it to . In general, we have that : we need to compute the two numbers below the one we want and then add them together. The sequence bears a striking resemblance to the Fibonacci sequence if you compare the definitions—this is a good example of how the Fibonacci sequence or similar sequences pop up in analyzing recursive algorithms.1
I've graphed for from 0 to 50. Note the scale on the y-axis, from 0 to 20 billion! grows exponentially, and gets really big really fast. Clearly this won't be a viable way of computing large Fibonacci numbers.
- A famous example is the Euclidean algorithm for computing the greatest common denominator, which has its worst performace for consecutive Fibonacci numbers.↩
Let's call the number of arithmetic operations we need to compute . , because those values are given to us. , because we need to add and . , because we need to compute and then add it to . In general, we have that : we need to compute the two numbers below the one we want and then add them together. The sequence bears a striking resemblance to the Fibonacci sequence if you compare the definitions—this is a good example of how the Fibonacci sequence or similar sequences pop up in analyzing recursive algorithms.1
I've graphed for from 0 to 50. Note the scale on the y-axis, from 0 to 20 billion! grows exponentially, and gets really big really fast. Clearly this won't be a viable way of computing large Fibonacci numbers.
- A famous example is the Euclidean algorithm for computing the greatest common denominator, which has its worst performace for consecutive Fibonacci numbers.↩