Question: Develop a recursive implementation that incorporates the ideas per- above for calculating the nth Fibonacci number. Compare the formance of the recursive method with
Develop a recursive implementation that incorporates the ideas per- above for calculating the nth Fibonacci number. Compare the formance of the recursive method with the iterative solution. What sequence of pairs of Fibonacci numbers would be needed to compute the 23rd Fibonacci number using the present algorithm? It is possible to multiply two numbers x and y by repeatedly halving y (i.e. integer division) when it is even and reducing it by 1 when it is odd. When y is odd the current value of x is accumulated. When y is even, x is doubled. Implement this multiplication algorithm. (Note: Doubling and halving operations correspond to "shift" operations which are very efficient on most computers.) It is possible to compute n! in O(log2 n) steps. Try to develop such an algorithm for computing n! (Ref. A. Shamir, "Factoring numbers in O(log n) arithmetic steps", Inf. Proc. Letts., 8, 28-31 (1979)).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
