Skip to content

added shuffle algorithm, it's implementation and problems related to it #6030

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 35 commits into from
Closed

Conversation

Darshan-Baligeri
Copy link

Pull Request Description
Overview
This pull request adds multiple shuffle algorithms to the repository, each accompanied by its implementation and distinct problems that demonstrate its use. The following algorithms have been included:

Unique Pair Shuffle: This algorithm randomly creates pairs from elements in an array while avoiding duplicate pairings. If the input array has an odd number of elements, it returns an empty result.

Group Shuffle: This function splits an array into a defined number of groups and shuffles the contents of each group independently. It also addresses scenarios where the requested number of groups is greater than the length of the array.

Shuffle by Range: This method allows for shuffling a specific section of an array while leaving elements outside that range unchanged. It includes checks to verify that the specified start and end indices are valid.

Weighted Shuffle: This algorithm shuffles an array based on the assigned weights of its elements, ensuring that elements with higher weights are more likely to appear earlier in the shuffled output.

Constrained Shuffling: This technique rearranges an array so that no element remains in its original position. It features validation to confirm that this requirement is satisfied.

Implementation Details
Each algorithm has been developed with a focus on handling edge cases and validating inputs effectively.
In-depth inline documentation is provided to enhance understanding and usability, making the code accessible to beginners.
Unique problems associated with each algorithm have been crafted to broaden the practical applications of the shuffling methods.
Testing
All algorithms have undergone rigorous testing with a variety of inputs to verify their functionality, including edge cases like empty arrays, single-element arrays, and invalid inputs.

Conclusion
These contributions enrich the algorithm library by introducing new, practical algorithms along with relevant problems, fostering further exploration and application in shuffle-related tasks.

@Darshan-Baligeri Darshan-Baligeri changed the title added shuffle algorithms, it's implementation and problem related to it added shuffle algorithm, it's implementation and problem related to it Oct 27, 2024
@Darshan-Baligeri Darshan-Baligeri changed the title added shuffle algorithm, it's implementation and problem related to it added shuffle algorithm, it's implementation and problems related to it Oct 27, 2024
@codecov-commenter
Copy link

codecov-commenter commented Oct 27, 2024

Codecov Report

Attention: Patch coverage is 57.14286% with 27 lines in your changes missing coverage. Please review.

Project coverage is 72.36%. Comparing base (a163816) to head (c2d5827).

Files with missing lines Patch % Lines
...thealgorithms/datastructures/trees/BinaryTree.java 59.01% 17 Missing and 8 partials ⚠️
src/main/java/com/thealgorithms/ciphers/AES.java 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6030      +/-   ##
============================================
- Coverage     72.37%   72.36%   -0.02%     
- Complexity     4981     5013      +32     
============================================
  Files           652      658       +6     
  Lines         17569    17663      +94     
  Branches       3385     3403      +18     
============================================
+ Hits          12716    12781      +65     
- Misses         4373     4398      +25     
- Partials        480      484       +4     

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

Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

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

Please remove main functions and add JUnit tests

@Darshan-Baligeri Darshan-Baligeri closed this by deleting the head repository Oct 28, 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.

3 participants