TheAlgorithms / Java

All Algorithms implemented in Java
MIT License
58.87k stars 19.06k forks source link

[FEATURE REQUEST] Basic Recursion #5502

Open Tuhinm2002 opened 18 hours ago

Tuhinm2002 commented 18 hours ago

What would you like to Propose?

I found Dynamic Programming is there but the basic Recursion is not there. Problems like finding power set or subsets can only be done using recursion. Recursion plays an crucial role for setting the strong foundation for Dynamic programming.

My test cases :

package com.thealgorithms.Recursion;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

import java.util.ArrayList;

public class SubsetsTest {

    @Test
    void subset(){
        String str = "abc";
        ArrayList<String> ans = new ArrayList<>();
        ArrayList<String> actual = new ArrayList<>();
        ans.add("abc");
        ans.add("ab");
        ans.add("ac");
        ans.add("a");
        ans.add("bc");
        ans.add("b");
        ans.add("c");
        ans.add("");

        Subsets.subset("",str,actual);
        assertEquals(ans.toString(),actual.toString());
    }
}

Issue details

There is no package for recursion and recursion problems like producing subsets and powerset

Additional Information

No response

dipeshsingh253 commented 17 hours ago

Hi @Tuhinm2002 , I would like to contribute to this. I am not able to understand what is required here. Can you explain it in a brief?

Thanks !!!

raxvab commented 12 hours ago

Is it still open for assignments?

Tuhinm2002 commented 2 hours ago

Is it still open for assignments?

No its not an assignment. It is a feature request originally opened by me. First read contribution.md file before contributing

dipeshsingh253 commented 2 hours ago

I guess @sujitgunjal is already working on it.

Tuhinm2002 commented 2 hours ago

I guess @sujitgunjal is already working on it.

Nope its originally requested by me as a feature. Its not an assignment

siriak commented 1 hour ago

@Tuhinm2002 so you want to add these features yourself, right? Feel free to create a PR with them and tests

Tuhinm2002 commented 56 minutes ago

@Tuhinm2002 so you want to add these features yourself, right? Feel free to create a PR with them and tests

Yeah I created a PR with the name feat: recursion subsets added. Please review it. And after it gets merge I will complete the package all at once in the next PR. Because in this PR it is not possible to edit 😅