C++ simple code base to understand iterative and recursive algorithms. What makes an iterative function faster?
IDE - Visual Studio
This project provides exposure to the Fibonacci Sequence, which is a sequence of numbers where each number is the sum of the two numbers before it.
This project provides two different approaches to calculating the Fibonacci Sequence:
- A simple loop (iterative method).
- A function which calls itself (recursive method) in order to solve bits of bigger problem and with smaller numbers, the recursive method works quite well. However, as the sequence continues to a bigger number, the repeated functions calls become burdensome and causes the function to lag.
****************************************************************************
Here is a screenshot of what the output should look like:
****************************************************************************
Here is the code base:
Sources
https://dev.to/khalilsaboor/fibonacci-recursion-vs-iteration--474l
Comments
Post a Comment