Skip to content

whyer123/Algorithm-Introduction---Fibonacci-Sequence

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Fibonacci benchmarking

This small script benchmarks four methods to compute Fibonacci numbers and plots the timings:

  • naive recursive
  • recursive with memoization (top-down DP)
  • bottom-up iterative (array-like)
  • matrix exponentiation (O(log n))

Usage

Run the script with n values you want to test:

python3 fib_bench.py 5 10 20 30 35 --output fib_times.png

Notes

  • The naive recursive method is exponential and will become infeasible quickly. By default the script skips running naive recursion for n > 35; use --allow-slow to force running it for larger n (not recommended).
  • The script saves a PNG plot (default fib_bench.png) showing timing lines for each method.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages