Question: code in c sometimes a recursive implementation provides an efficient...
Code in C++
Sometimes a recursive implementation provides an efficient solution to a task, and sometimes it is inefficient. This challenge problem asks you to implement the Fibonacci sequence in different ways than the recursive implementation from class. Specifically, write two additional non-recursive versions for finding the first 20 Fibonacci numbers. (Your programs may do all the computations in main() rather than having the computation of each Fibonacci number done in a function.)
• A version that only holds in memory the current and two previous Fibonacci numbers as it computes the numbers one by one.
• A version that computes the numbers and stores them in an array as it computes them.
Once you have implemented these techniques think about their advantages and disadvantages when compared to each other and to the recursive implementation. More generally, when is a recursive implementation preferable, and when are other possible implementations preferable?