Commit Graph

935 Commits

Author SHA1 Message Date
Saahil Mahato
50b1bcdc67 feat: add damerau-levenshtein distance algorithm (#6706)
* feat: add damerau-levenshtein distance algorithm

* refactor: remove useless parentheses

* refactor: add class link to test
2025-10-08 18:09:18 +02:00
Yash Rajput
b031a0bbba Adding PiApproximation algo (#6602)
* Adding PiApproximation algo

* Added clang formatting

* Added private method

* checkstyle fix

* checkstyle fix

---------

Co-authored-by: Deniz Altunkapan <93663085+DenizAltunkapan@users.noreply.github.com>
2025-10-08 12:16:14 +00:00
Udaya Krishnan.M
5f8d8eeb7b Added Pretty Display method and BSTRecursiveGenericTests.java (#6621)
* added binarysearchtree

* added binarysearchtree

* updated

* updated the test values

* updated build issues

* updated

* updated

* updated

* updated

* updated

* updated

* updated

* added pretty display method

* added pretty display method

* updated pretty Display and added BSTRecursiveGenericTest.java

* updated pretty Display and added BSTRecursiveGenericTest.java

* updated pretty Display and added BSTRecursiveGenericTest.java

* updated pretty Display and added BSTRecursiveGenericTest.java

* updated pretty Display and added BSTRecursiveGenericTest.java

* added pretty display method

* updated pretty Display and added BSTRecursiveGenericTest.java

* updated pretty Display and added BSTRecursiveGenericTest.java

* updated pretty Display and added BSTRecursiveGenericTest.java

---------

Co-authored-by: Krishnan M <2318467@cognizant.com>
Co-authored-by: Deniz Altunkapan <93663085+DenizAltunkapan@users.noreply.github.com>
2025-10-08 11:55:38 +00:00
Sriram kulkarni
959ced9076 Added mos algorithm and dice thrower (#6591)
* Add Sum of Squares algorithm implementation

* Format code and add Wikipedia URL for Lagrange's theorem

* Fixed clang-format issues

* Added Mo's Algorithm and DiceThrower recursive algorithms

- Mo's Algorithm: Square root decomposition for offline range queries(Imp in CP)
- DiceThrower: Recursive backtracking for dice combinations(very imp)
- Both algorithms include comprehensive test suites
- Formatted with clang-format and i follow contribution guidelines

* Fixed checkstyle violation

* Fixed SpotBugs issue

* Added in PMD exclusions

* Improved test coverage for better Codecov scores.

* Fixed clang-format issues in test files

* Add Mo's Algorithm and DiceThrower algorithms with comprehensive tests
* Fixed PartitionProblem.java documentation comment placement
2025-10-08 11:51:44 +00:00
Dheeraj Kumar
c06dc292fe feat(ciphers): Add PermutationCipher implementation(enhance #6697) (#6700)
* feat(ciphers): Add PermutationCipher implementation with comprehensive tests

- Implement PermutationCipher class for transposition encryption/decryption
- Add encrypt() and decrypt() methods with permutation key support
- Include robust key validation (1-based positions, no duplicates)
- Implement automatic padding for incomplete blocks using 'X' character
- Add comprehensive error handling with descriptive exceptions
- Create 20+ JUnit test cases covering encryption, decryption, edge cases
- Support various key sizes and text processing (spaces removal, case handling)
- Include detailed JavaDoc documentation with algorithm explanation

Algorithm Details:
- Divides plaintext into blocks based on key length
- Rearranges characters within each block according to permutation positions
- Supports round-trip encryption/decryption with inverse permutation
- Handles edge cases: empty strings, single character keys, padding

Tests include: basic functionality, different key sizes, error validation,
real-world examples, and edge case handling.

* Run PermutationCipherTest using Maven

* refactor(PermutationCipher): clean up code by removing unnecessary whitespace and comments

* fix(tests): remove unnecessary whitespace in test assertion for encryption

* fix(tests): correct indentation in assertion for encryption verification

---------

Co-authored-by: a <alexanderklmn@gmail.com>
2025-10-08 08:42:58 +02:00
Saahil Mahato
79dc71db89 feat: add wu's line drawing algorithm (#6695)
* feat: add wu's line drawing algorithm

* refactor: reorganize internal class declaration

---------

Co-authored-by: a <alexanderklmn@gmail.com>
2025-10-07 21:42:53 +02:00
Saahil Mahato
9f985b2549 feat: add euler primality test (#6680)
* feat: add euler primality test

* refactor: use fixed seed

* fix: more unit test coverage

* fix: add mock tests for edge cases

* fix: styling issues

* refactor: remove duplicate tests

* refactor: reduce static imports

* refactor: remove unnecessary tests

* refactor: move to maths package

---------

Co-authored-by: a <alexanderklmn@gmail.com>
2025-10-06 20:23:32 +02:00
ananya-research
8ca2d9f820 Create zero_one_bfs.java (#6560)
* Create zero_one_bfs.java

* Rename zero_one_bfs.java to ZeroOneBfs.java

* Update ZeroOneBfs.java

* Update ZeroOneBfs.java

* Create ZeroOneBfsTest.java

* Update ZeroOneBfsTest.java

---------

Co-authored-by: a <alexanderklmn@gmail.com>
2025-10-06 20:14:32 +02:00
Priyanshu Kumar Singh
9484c7eead FEAT(geometry): Add Haversine formula and fix build issues (#6650)
[FEAT] Implemented Haversine Formula

Co-authored-by: Priyanshu1303d <priyanshu130d@gmail.com>
2025-10-05 20:28:06 +02:00
Banula Kumarage
e6cb96f390 Dev: Added CoordinateConverter for Cartesian and Polar coordinate conversions (#6628)
Added CoordinateConverter utility class for Cartesian and Polar coordinate conversions
2025-10-05 14:26:13 +03:00
Banula Kumarage
a0b6c52790 Dev: Added algorithm to find the nth number in the Sylvester Sequence (#6613)
Added algorithm to find the nth number in the SylvesterSequence
2025-10-04 15:56:08 +02:00
Banula Kumarage
6d5170999a Dev: Added NumberPersistence utility class to find multiplicative and additive persistance (#6612)
* Add NumberPersistence utility class with multiplicative and additive persistence methods

* Fixed identified style issues
2025-10-04 12:55:26 +02:00
JeevaRamanathan
7e29be3ad8 Added isogram utility class and unit tests (#6594)
* added isogram utility class and unit tests

Signed-off-by: JeevaRamanathan <jeevaramanathan.m@infosys.com>

* checking lint issue

Signed-off-by: JeevaRamanathan <jeevaramanathan.m@infosys.com>

* checking lint issue

Signed-off-by: JeevaRamanathan <jeevaramanathan.m@infosys.com>

* checking lint issue

Signed-off-by: JeevaRamanathan <jeevaramanathan.m@infosys.com>

* checking lint issue

Signed-off-by: JeevaRamanathan <jeevaramanathan.m@infosys.com>

* checking lint issue

Signed-off-by: JeevaRamanathan <jeevaramanathan.m@infosys.com>

* checking lint issue

Signed-off-by: JeevaRamanathan <jeevaramanathan.m@infosys.com>

* checking lint issue

Signed-off-by: JeevaRamanathan <jeevaramanathan.m@infosys.com>

* checking lint issue

Signed-off-by: JeevaRamanathan <jeevaramanathan.m@infosys.com>

* linter fix

Signed-off-by: JeevaRamanathan <jeevaramanathan.m@infosys.com>

* fix: HideUtilityClassConstructor

Signed-off-by: JeevaRamanathan <jeevaramanathan.m@infosys.com>

* linter fix

Signed-off-by: JeevaRamanathan <jeevaramanathan.m@infosys.com>

* updated isogram class to final

Signed-off-by: JeevaRamanathan <jeevaramanathan.m@infosys.com>

* pipeline bug fixing

Signed-off-by: JeevaRamanathan <jeevaramanathan.m@infosys.com>

* renamed function names and few fixes w.r.t to suggestion

Signed-off-by: JeevaRamanathan <jeevaramanathan.m@infosys.com>

---------

Signed-off-by: JeevaRamanathan <jeevaramanathan.m@infosys.com>
2025-10-03 14:33:12 +03:00
Yash Rajput
8d14b492fd Added CountBitsFlip algo (#6603)
* Added CountBitsFlip aldo

* checkstyle fix

* checkstyle fix

---------

Co-authored-by: Alx <alexanderklmn@gmail.com>
2025-10-03 12:52:53 +03:00
Banula Kumarage
506b6d1ab2 DEV: Implementing Time Conversion Algorithm (#6556)
* Added-time-converter-algorithm

* Updated-java-docs

* Fixed-formatting-issues

* Enhanced-unit-tests

* Fixed-failing-check-style

---------

Co-authored-by: Deniz Altunkapan <93663085+DenizAltunkapan@users.noreply.github.com>
2025-10-02 18:31:19 +00:00
Anubhav
977c982904 Add Minimum Window Substring algorithm in Sliding Window package (#6553)
* Create MinimumWindowSubstring.java

* Create MinimumWindowSubstringTest.java

* correct MinimumWindowSubstringTest.java

* Added more test cases

* Update MinimumWindowSubstringTest.java

* Update MinimumWindowSubstringTest.java

* Update MinimumWindowSubstringTest.java

* Update MinimumWindowSubstringTest.java

* Update MinimumWindowSubstringTest.java

* Update MinimumWindowSubstringTest.java

* Added test case "AAABBC" "AABC"

---------

Co-authored-by: Deniz Altunkapan <93663085+DenizAltunkapan@users.noreply.github.com>
2025-10-02 20:25:48 +02:00
Sourav Saha
f43ecd573a feat: add comprehensive test coverage for ProcessDetails entity class (#6590)
* feat: add comprehensive test coverage for ProcessDetails entity class (#6588)

- Add ProcessDetailsTest.java with 20 comprehensive test methods
- Cover all constructors, getters, and setters
- Include edge cases: null values, negatives, zeros, max values
- Add real-world scheduling scenario tests
- Ensure 100% line coverage for ProcessDetails class
- Follow project checkstyle rules and conventions

Fixes #6588

* fix: resolve SpotBugs UC_USELESS_OBJECT warning in ProcessDetailsTest

- Add assertions for process1 in testMultipleProcessesIndependence method
- Verify both processes are properly tested for independence
- Ensure all created objects are meaningfully used in tests

Fixes SpotBugs warning: UC_USELESS_OBJECT at line 224

---------

Co-authored-by: Oleksandr Klymenko <alexanderklmn@gmail.com>
2025-10-02 20:15:03 +02:00
Nithin U
2be984fdf5 To add Implementation of Base64 Algorithm (#6586)
* feat: base64 algorithm implementation

* feat: test coverage implementation of Base64Test.java

* Update DIRECTORY.md

* fix: build and lint fix update

* patch: linter fix

* fix: enforce strict RFC 4648 compliance in Base64 decoding

* fix: enforce strict rfc 4648 compliance in base64 decoding

---------

Co-authored-by: Oleksandr Klymenko <alexanderklmn@gmail.com>
2025-10-02 19:57:14 +02:00
Sriram kulkarni
d8ddb07b7e Added Sum of Squares Lagrange's Four Square algorithm implementation (#6583)
* Add Sum of Squares algorithm implementation

* Format code and add Wikipedia URL for Lagrange's theorem

* Fixed clang-format issues

---------

Co-authored-by: Oleksandr Klymenko <alexanderklmn@gmail.com>
2025-10-02 10:44:36 +03:00
Sourav Saha
15695c6e54 Fix MiniMaxAlgorithm setScores bug and add comprehensive tests (#6566)
* Fix MiniMaxAlgorithm setScores bug and add comprehensive tests

- Fix bug in setScores method where scores.length % 1 == 0 always returned true
- Add isPowerOfTwo helper method to properly validate array length
- Add comprehensive unit tests covering edge cases and algorithm correctness
- Tests include validation for power of 2 check, minimax logic, and error handling

Fixes issue with incorrect validation logic in MiniMaxAlgorithm.setScores()

* Fix Checkstyle violations and improve setScores validation

- Replace star imports with explicit imports in test file
- Remove trailing whitespaces from all lines
- Add proper file ending newline
- Improve setScores method to handle edge cases properly
- Use direct bit manipulation for power-of-2 check as suggested
- Ensure error message is printed and scores remain unchanged for invalid input

All Checkstyle violations resolved and tests pass successfully.

* Add missing newline at end of MiniMaxAlgorithmTest.java

- Fix Checkstyle violation: NewlineAtEndOfFile
- Ensure file ends with proper newline character
- All tests continue to pass successfully

* Fix PMD violation by utilizing isPowerOfTwo method

- Replace inline bit manipulation with isPowerOfTwo method call
- Resolves PMD UnusedPrivateMethod violation
- Maintains same validation logic and error handling
- All tests continue to pass successfully

* test: improve MiniMaxAlgorithm test coverage for CodeCov

- Add comprehensive test cases for isPowerOfTwo function edge cases
- Test setScores method with various invalid array lengths (0, 3, 5, 6, 7, 9, 10, 15)
- Add tests for large valid powers of 2 (up to 64 elements)
- Ensure complete coverage of error handling branches
- Increase test count from 14 to 19 tests
- Fix partial coverage issues identified in CodeCov report

Resolves CodeCov coverage gaps in MiniMaxAlgorithm.java

* Fix checkstyle errors

* Fix checkstyle errors

---------

Co-authored-by: ssaha <ssaha@wiley.com>
Co-authored-by: Deniz Altunkapan <93663085+DenizAltunkapan@users.noreply.github.com>
2025-10-02 09:24:25 +02:00
Sivasuthan Sukumar
f8f315eaa8 Extend Graph Algorithms: Added Two Popular Algorithms: BronKerbosch, EdmondsKarp (#6576)
* Bron–Kerbosch algorithm added.

* test:Bron–Kerbosch algorithm added.

* lint checked.

* clang-format linting checked.

* lint checked in remote

Removed duplicate import statements for assertions.

* Remove unnecessary blank line in BronKerboschTest

* EdmondsKarp algorithm added.

* reformatted

---------

Co-authored-by: Oleksandr Klymenko <alexanderklmn@gmail.com>
2025-10-01 21:44:43 +02:00
Richa Kiran
5e9d9f7337 Added Circular Doubly Linked List in the datastructures section (#6565) 2025-10-01 15:59:15 +03:00
Milad Sadeghi
ef681e844d DEV: Implementing Alternative String Arrange (#6551) 2025-09-29 13:13:50 +03:00
Hetu Kariya
fb12971fd6 Added BitwiseGCD.java and BitwiseGCDTest.java (#6545) 2025-09-27 13:02:34 +02:00
Rahul P
5fee204773 Added PriorityQueueSort algorithm and Tests (#6532)
* Added PriorityQueueSort.java

Implemented PriorityQueueSort using Java's PriorityQueue (Min-Heap).
- Returns the array sorted in ascending order
- Time complexity: O(n log n)
- Space complexity: O(n)

* Added tests for PriorityQueueSort

* Update PriorityQueueSortTest.java

* Fixed formatting and added full coverage tests for PriorityQueueSort

* Update PriorityQueueSort.java

* Update PriorityQueueSort.java

* Update PriorityQueueSort.java

* Update PriorityQueueSortTest.java

* Update PriorityQueueSort.java

* Update PriorityQueueSort.java

* Update PriorityQueueSort.java

* Fix formatting with clang-format
2025-09-18 20:02:15 +02:00
Nithin U
85a2df46ad To add Suffix array algorithm implementation (#6530)
* adding Suffix Array Implementation

* adding test for Suffix Array

* patch: lint fix in SuffixArray.java

* patch: lint fix in SuffixArrayTest.java

* fix: private constructor update

* patch: lint fix in suffix array impl

* fix: lint issue line blankspace removal

* fix: checkstype issue

* fix: lint format issue

* Update DIRECTORY.md
2025-09-17 17:56:10 +02:00
Priyansh
1393f5ea6b Added-> DisjointUnion Set by Size (#6514)
* Added-> DisjointUnion Set by Size

* Add tests for DisjointSetUnionBySize

---------

Co-authored-by: Deniz Altunkapan <93663085+DenizAltunkapan@users.noreply.github.com>
2025-09-03 19:05:12 +02:00
Nihar Kakani
27ada8a649 Migrate recursive reverse string method and tests to ReverseString (#6504)
* Migrate recursive reverse string method and tests to ReverseString

- Moved recursive reverse method from ReverseStringRecursive.java to ReverseString.java
- Moved tests from ReverseStringRecursiveTest.java to ReverseStringTest.java
- Deleted old ReverseStringRecursive files

* Fix formatting for ReverseStringTest.java as per clang-format linter
2025-08-27 16:59:04 +02:00
Vicky
3961b1dab9 fix: revert ReverseStack deletion and verify linting (#6474) (#6494)
* fix: revert ReverseStack deletions and ensure lint compliance

* Fix formatting for ReverseStack and test files

* Delete ReverseStackUsingRecursion and its test as requested

---------

Co-authored-by: Deniz Altunkapan <93663085+DenizAltunkapan@users.noreply.github.com>
2025-08-22 07:41:36 +02:00
Deniz Altunkapan
6c24d27b03 Move methods from others to correct packages (#6475)
refactor: Move methods from `others` package to their respective packages
2025-08-18 22:28:19 +02:00
Stathis Veinoglou
2dd6a13707 Add DFS with parent-completion constraint for DAG traversal (#6467)
* Add DFS with parent-completion constraint for DAG traversal

* warning in PartitionProblem.java affecting tests

* added clang-format and updated javadoc

* optimized imports and rechecked camelCase format in tests

* removed .* import and made small visual change

* replaced a inline return with correct {} block

* Removed changed in PartitionProblem.java, Renamed class name to be straightforward about the implementation.Added full names instead of shortcuts, and included record.

* updated for clang format

---------

Co-authored-by: Deniz Altunkapan <93663085+DenizAltunkapan@users.noreply.github.com>
2025-08-15 16:41:52 +00:00
ptzecher
657f433413 Hopcroft karp Algorithm implementation and tests (#6465)
* Add Hopcroft-Karp algorithm and tests

* Adding wikipedia url for Algorithm

* fixing test issues

* remove unused field flagged by PMD
2025-08-14 19:42:51 +02:00
Navaneedan S
e09c98578f Add ReverseStringUsingStack (#6452)
* Refactored ReverseStringUsingStack
* Add ReverseStringUsingStack
* Refactored ReverseStringUsingStack
* Closes #6451
2025-08-01 21:16:10 +02:00
Oleksandr Klymenko
24f4090210 testing: improve MergeKSortedLinkedListTes (#6445)
testing: improve MergeKSortedLinkedListTest

Co-authored-by: Deniz Altunkapan <93663085+DenizAltunkapan@users.noreply.github.com>
2025-07-27 10:50:41 +02:00
Oleksandr Klymenko
0081d5c73a testing: improve testing CRCAlgorithmTest (#6444)
* testing: improve testing CRCAlgorithmTest

* style: formatting fix
2025-07-27 10:46:42 +02:00
Oleksandr Klymenko
066a10979b testing: improve BloomFilterTest (#6443)
* testing: improve BloomFilterTest

* style: fix formatting
2025-07-26 19:38:25 +02:00
Lucas Gomes
2eb80fb843 Remove duplicate SimpleSort (same logic as ExchangeSort) (#6441)
* Remove duplicate SimpleSort (same logic as ExchangeSort)

* Removed test class for SimpleSort as it was also duplicate

---------

Co-authored-by: Lucas G <lucasgomesm1808@gmail.com>
2025-07-26 10:34:00 +02:00
Oleksandr Klymenko
032f75c0f4 testing: improve DisjointSetUnionTest (#6440)
* testing: improve DisjointSetUnionTest

* testing: redundant variable for DisjointSetUnionTest
2025-07-25 18:04:52 +00:00
Oleksandr Klymenko
040d3850ac testing: improve BagTest (#6435)
* testing: improve BagTest

* style: fix checkstyle for BagTest

* testing: redundant test
2025-07-25 18:01:12 +00:00
Oleksandr Klymenko
edb8167374 testing: improve test coverage NodeStackTest (#6432)
* testing: improve test coverage NodeStackTest

* style: fix style issues

* testing: fix type

* testing: fix import

* testing: fix import
2025-07-25 19:58:15 +02:00
Oleksandr Klymenko
fc07cd806e testing: improve test coverage StackOfLinkedListTest (#6430)
* testing: improve test coverage StackOfLinkedListTest

* testing: fix spotbugs
2025-07-24 21:36:52 +02:00
Oleksandr Klymenko
4f16ad0b0e testing: improve test coverage DequeTest (#6429)
testing: improve test coverage DequeTest
2025-07-24 18:41:02 +00:00
Oleksandr Klymenko
ac5849323e testing: improve test coverage CursorLinkedListTest (#6428)
* testing: improve test coverage CursorLinkedListTest

* style: fix checkstyle formatting
2025-07-24 20:34:31 +02:00
Oleksandr Klymenko
ec7b654d0b testing: improve StackArrayTest (#6424)
testing: improve StackArrayTest
2025-07-24 12:42:33 +03:00
Oleksandr Klymenko
699271665d testing: improve QueueTest (#6423)
* testing: improve QueueTest

* testing: fix test
2025-07-23 22:02:52 +02:00
Oleksandr Klymenko
7e3fbae1a4 testing: improve SortStackTest (#6422)
testing: improve SortStackTest

Co-authored-by: Deniz Altunkapan <93663085+DenizAltunkapan@users.noreply.github.com>
2025-07-23 17:09:18 +02:00
Oleksandr Klymenko
073b6f15a8 testing: improve CircularBufferTest (#6418)
* testing: improve CircularBufferTest

* style: redundant whitespace

---------

Co-authored-by: Deniz Altunkapan <93663085+DenizAltunkapan@users.noreply.github.com>
2025-07-23 07:44:38 +02:00
Oleksandr Klymenko
3304cf2e58 testing: improve QueueByTwoStacksTest (#6416)
testing: improve QueueByTwoStacksTest
2025-07-22 19:33:55 +02:00
Oleksandr Klymenko
ceead5eccd testing: refactor to ParameterizedTest PrefixEvaluatorTest (#6415)
testing: refactor to ParameterizedTest PrefixEvaluatorTest

Co-authored-by: Deniz Altunkapan <93663085+DenizAltunkapan@users.noreply.github.com>
2025-07-22 17:22:08 +00:00
Vishwajeet Deshmane
cfd784105b Feat(Improved): Add 0/1 Knapsack Problem: Recursive and Tabulation (Bottom-Up DP) Implementations in Java along with their corresponding Tests (#6425)
* feat: Add 0/1 Knapsack and its tabulation implementation with their corresponding tests

* feat: Add 0/1 Knapsack and its tabulation implementation with their corresponding tests

* feat: Add 0/1 Knapsack and its tabulation implementation with their corresponding tests

* Feat:add 0/1knapsack and 0/1knapsacktabulation along with their tests

* Feat:add 0/1knapsack and 0/1knapsacktabulation along with their tests

* Feat:add 0/1knapsack and 0/1knapsacktabulation along with their tests

---------

Co-authored-by: Oleksandr Klymenko <alexanderklmn@gmail.com>
2025-07-22 19:17:24 +02:00