Skip to content

Add basic recursion algorithms #5505

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

shivammm21
Copy link

Summary of Changes

This pull request adds a new package recursion under com.thealgorithms to implement basic recursion algorithms, which are fundamental for understanding more complex techniques such as dynamic programming.

Changes in Detail:

  • Subsets.java: Generates all subsets of a string using recursion.
  • Fibonacci.java: Computes the nth Fibonacci number using a recursive approach.
  • Factorial.java: Recursively calculates the factorial of a number.
  • Permutations.java: Recursively generates all permutations of a string.
  • TowerOfHanoi.java: Solves the Tower of Hanoi problem for n disks using recursion.

Checklist:

  • 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 src/main/java/com/thealgorithms/recursion/Subsets.java clang-format -i --style=file src/main/java/com/thealgorithms/recursion/Fibonacci.java clang-format -i --style=file src/main/java/com/thealgorithms/recursion/Factorial.java clang-format -i --style=file src/main/java/com/thealgorithms/recursion/Permutations.java clang-format -i --style=file src/main/java/com/thealgorithms/recursion/TowerOfHanoi.java.

Additional Notes

This proposal aims to fill the gap by introducing basic recursion algorithms, which are crucial for building a strong foundation for understanding advanced topics like dynamic programming.

@codecov-commenter
Copy link

codecov-commenter commented Oct 1, 2024

Codecov Report

Attention: Patch coverage is 0% with 30 lines in your changes missing coverage. Please review.

Project coverage is 52.19%. Comparing base (7f60d57) to head (e5a929d).
Report is 129 commits behind head on master.

Files with missing lines Patch % Lines
...java/com/thealgorithms/recursion/TowerOfHanoi.java 0.00% 8 Missing ⚠️
...java/com/thealgorithms/recursion/Permutations.java 0.00% 7 Missing ⚠️
...main/java/com/thealgorithms/recursion/Subsets.java 0.00% 7 Missing ⚠️
...in/java/com/thealgorithms/recursion/Factorial.java 0.00% 4 Missing ⚠️
...in/java/com/thealgorithms/recursion/Fibonacci.java 0.00% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5505      +/-   ##
============================================
- Coverage     52.28%   52.19%   -0.10%     
- Complexity     3256     3257       +1     
============================================
  Files           525      530       +5     
  Lines         15185    15215      +30     
  Branches       2887     2888       +1     
============================================
+ Hits           7940     7941       +1     
- Misses         6920     6950      +30     
+ Partials        325      324       -1     

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

@siriak
Copy link
Member

siriak commented Oct 2, 2024

The factorial is already implemented here

public final class Factorial {

Please also check other algorithms for duplicates, also fix build PR check

@vil02
Copy link
Member

vil02 commented Oct 3, 2024

These algorithms already exist:

If you want to contribute, you can do the following:

  • find any class, which has the main method,
  • remove it (i.e. the main method),
  • add proper tests for this class.

Please work on one class in single PR.

@vil02 vil02 closed this Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants