Skip to content

Implement Parentheses Generator #5096

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

Merged
merged 10 commits into from
Apr 5, 2024
Merged

Implement Parentheses Generator #5096

merged 10 commits into from
Apr 5, 2024

Conversation

sozelfist
Copy link
Contributor

  • 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

Copy link
Member

@vil02 vil02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two questions (just questions, I want to know your reasons):

  • why did you use List<String> and not another container? (maybe set),
  • what do you think about marking methods of ParenthesesGenerator as static?

In general the code looks good.

@sozelfist
Copy link
Contributor Author

sozelfist commented Apr 4, 2024

Two questions (just questions, I want to know your reasons):

  • why did you use List<String> and not another container? (maybe set),
  • what do you think about marking methods of ParenthesesGenerator as static?

In general the code looks good.

  1. The List<String> data structure was chosen for its simplicity and efficiency in this implementation. Using a List allows us maintain the order of generated parentheses combinations. While a Set<String> could ensure uniqueness of combinations, it might not preserve the order of generation, which could be important in some cases.

  2. Marking the methods of ParenthesesGenerator as static could be appropriate depending on the intended usage and design considerations. If the methods do not rely on instance-specific state or behavior, marking them as static could enhance code readability and usage simplicity. Static methods can be called without needing to instantiate an object of the class, which can be beneficial in scenarios where the class serves primarily as a utility or helper. However, if the methods need access to instance variables or if there is a possibility of different instances requiring different behaviors, then keeping them as instance methods would be more appropriate.

  3. In the case of the ParenthesesGenerator class, marking the methods as static could be appropriate since the methods do not rely on instance-specific state or behavior. They operate solely on the input parameters provided to them and do not require access to any instance variables. Therefore, marking the methods as static would make the class more of a utility or helper class, simplifying its usage by allowing clients to call the methods directly without instantiating an object of the class. This approach enhances code readability and promotes a clearer separation of concerns.

@sozelfist
Copy link
Contributor Author

sozelfist commented Apr 4, 2024

I will change ParathensesGenerator's methods to static later. Appreciate your questions @vil02

@sozelfist sozelfist requested a review from vil02 April 5, 2024 02:18
Copy link
Member

@vil02 vil02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost done!

@sozelfist sozelfist requested a review from vil02 April 5, 2024 12:17
@vil02 vil02 merged commit c53f178 into TheAlgorithms:master Apr 5, 2024
5 checks passed
@sozelfist sozelfist deleted the backtracking/gen-parents branch April 5, 2024 23:15
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.

2 participants