Java icon indicating copy to clipboard operation
Java copied to clipboard

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

Open Darshan-Baligeri opened this issue 1 year ago • 1 comments

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 avatar Oct 27 '24 05:10 Darshan-Baligeri

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 :warning:
src/main/java/com/thealgorithms/ciphers/AES.java 0.00% 2 Missing :warning:
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     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Oct 27 '24 05:10 codecov-commenter