Computing Fibonacci Numbers with and without Dynamic Programming
A comparison of the time required to compute Fibonacci numbers, also illustrating elements of the C/C++ Style Guide
Functions
fibonacci.c File Reference
#include <stdio.h>
#include <time.h>
Include dependency graph for fibonacci.c:

Functions

int fibSeq1 (int n)
 
int fibSeq2Helper (int n, int fibArr[])
 
int fibSeq2 (int n)
 
int main ()
 

Detailed Description


Remarks
computation and timing of elements of the Fibonnaci sequence * using the basic recurisve formula for the sequence * with and without dynamic prog. *
Author
Henry M. Walker *
Date
August 14, 2022 *
Remarks
References *
Dynamic Programming: Anany Levitin, "The Design and * and Analysis of Algorithms", Second Edition, * Chapter 8: Dynamic Programming *
Dynamic Programming: Anany Levitin, "The Design and * and Analysis of Algorithms", Second Edition, * Section 2.5: Example: Computing the nth Fibonacci Number *
People participating with Problem/Progra Discussions: * None *

Function Documentation

◆ fibSeq1()

int fibSeq1 ( int  n)

compute the nth fibonacci number directly, * using the recursive definition of the sequence *

Parameters
nthe nth Fibonacci number to be computed * (starting the sequence at index 0) *
Precondition
0 <= n *
Returns
the nth Fibonacci number *
Here is the caller graph for this function:

◆ fibSeq2()

int fibSeq2 ( int  n)

compute the nth fibonacci number, * using the recursive definition and dynamic programming *

Parameters
nthe nth Fibonacci number to be computed * (starting the sequence at index 0) *
Precondition
0 <= n *
Returns
the nth Fibonacci number *
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fibSeq2Helper()

int fibSeq2Helper ( int  n,
int  fibArr[] 
)

helper function to compute the nth fibonacci number, * using the recursive definition and dynamic programming *

Parameters
nthe nth Fibonacci number to be computed * (starting the sequence at index 0) *
fibArran initialize array, recording * Fibonacci numbers already computed *
Precondition
0 <= n <= 1 + length of fibArr array *
Returns
the nth Fibonacci number *
Here is the caller graph for this function:

◆ main()

int main ( )

main procedure controls computation, timing, and printing *

Here is the call graph for this function: