Visitar URL original
[FEATURE REQUEST] Backtracking algorithms (All combinations) · Issue #3912 · TheAlgorithms/Java · GitHub
The Wayback Machine - https://web.archive.org/web/20230315102658/https://github.com/TheAlgorithms/Java/issues/3912
Skip to content
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

[FEATURE REQUEST] Backtracking algorithms (All combinations) #3912

Open
TheClerici opened this issue Mar 9, 2023 · 5 comments
Open

[FEATURE REQUEST] Backtracking algorithms (All combinations) #3912

TheClerici opened this issue Mar 9, 2023 · 5 comments

Comments

@TheClerici
Copy link
Contributor

What would you like to Propose?

I would like to add the all combinations algorithm!

Issue details

Although it is already in another repository from the Algorithms group (Python), I was unable to locate it in the folders (Java).

Additional Information

In this problem, we want to determine all possible combinations of k numbers out of 1 ... n. We use backtracking to solve this problem.

  • Example:

generate_all_combinations(n=4, k=2)
[[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]

@siriak
Copy link
Member

siriak commented Mar 9, 2023

@TheClerici
Copy link
Contributor Author

It is a little bit different, as the one you send is the combination in an array, and in this situation is from 1...n

@TheClerici
Copy link
Contributor Author

This is the sister repository with the problem I'm talking about, https://github.com/TheAlgorithms/Python/blob/master/backtracking/all_combinations.py lmk to start it!

@siriak
Copy link
Member

siriak commented Mar 10, 2023

You could just create a function that creates an array with values from 1 to n and calls the already implemented combination function, right? Feel free to do that and I'll review

@TheClerici
Copy link
Contributor Author

Sure, I can do that

debasishbsws pushed a commit that referenced this issue Mar 10, 2023
* ArrayCombination function which uses Combination.java by creating an array of 1 to n

* modified tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants