Skip to content

Conversation

princekotadia
Copy link

Title:
Added a Optimized Fibonacci Implementation (O(n) Version)

Changes included:

  • Added file FibonacciOptimized.java in src\main\java\com\thealgorithms\recursion. The file includes Optimized Fibonacci method.

Benefits:

  • Avoids exponential runtime of the simple recursive method
  • Efficient for large Fibonacci numbers
  • Maintains readability and simplicity for educational use

Friendly Note:
I’ve kept the original simple recursive implementation intact so that the repository still provides the classic educational example. This optimized version is added as an alternative for users who want better performance. I hope this addition is useful, and I’m happy to make adjustments if needed!


  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new code is formatted with clang-format -i --style=file path/to/your/file.java
@codecov-commenter
Copy link

codecov-commenter commented Oct 17, 2025

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.84%. Comparing base (4858ec9) to head (c875570).

Files with missing lines Patch % Lines
...om/thealgorithms/recursion/FibonacciOptimized.java 0.00% 3 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@ ## master #6825 +/- ## ============================================ - Coverage 77.85% 77.84% -0.02%  Complexity 6359 6359 ============================================ Files 731 732 +1 Lines 21187 21190 +3 Branches 4140 4140 ============================================ Hits 16495 16495 - Misses 4034 4037 +3  Partials 658 658 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
@princekotadia princekotadia marked this pull request as ready for review October 17, 2025 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants