Anon10087,
I want to take a look at your source code. Please point me to it in your home directory.
Thanks,
Anup
recursion program :- virtuqwork/prgc/functions/easy/ then myapp.c
iterative program:- virtuqwork/prgc/fucntions/easy/ then iter.c
Thanks
Anon10087
Anon10087,
The indentation in the program was bad, I have fixed it. You can indent an area in vim by first selecting it (ESC followed by v, then arrow keys or h j k l for navigating) followed by pressing =
On execution time, the results which you are getting are correct. However, you should also increase the value of input and see if you get any difference. Try to analyze as to why there is no difference. How many times is your function called in recursive implementation and how many times does the loop executed in iterative implementation. We do a much more detailed analysis of Fibonacci in Data Structures modules, but, you should be able to figure out that the number of times fib function is called is very high in the recursive version. You can find this out if you try to execute fib(5) using pen-and-paper.
Cheers,
Anup
Thanks sir![]()
Cool.
Anup