* Add Tower of Hanoi recursive algorithm with tests
* Fix SpotBugs issues and format TowerOfHanoi tests
* Enhance existing TowerOfHanoi and remove duplicate recursion version
* Fix clang-format issue
---------
Co-authored-by: Deniz Altunkapan <deniz.altunkapan@outlook.com>
* fix:shape's dimension constraints added correctyl (issue id: #7260)
* fix: base changed to baseLength for better understanding
* fix: base changed to baseLength for better understanding
* base changed to baseLength for better understanding
* fix:cleared some format issues
* fix:cleared some format issues
### Summary
This PR makes small readability and maintainability improvements to the algorithm implementation.
### Changes
- Removed a redundant `n < 0` validation check since the method contract already ensures valid `n`
- Replaced `current.remove(current.size() - 1)` with `current.removeLast()` to better express backtracking intent
### Rationale
- Simplifies input validation without changing behavior
- Uses the `Deque` API to make the backtracking step clearer and less error-prone
### Impact
- No change in algorithm logic or time/space complexity
- Output remains identical
Co-authored-by: Swati Vusurumarthi <swativs869@gmail.com>
refactor: remove duplicate algorithm implementations
Removed the following duplicate implementations:
- searches/PerfectBinarySearch.java (duplicate of IterativeBinarySearch)
- searches/SortOrderAgnosticBinarySearch.java (duplicate of OrderAgnosticBinarySearch)
- strings/LongestPalindromicSubstring.java (duplicate of dynamicprogramming version)
- strings/ValidParentheses.java (duplicate of stacks version)
- others/cn/HammingDistance.java (duplicate - strings version handles text)
- others/NewManShanksPrimeTest.java (orphan test in wrong package)
Updated DIRECTORY.md to reflect the changes.
Fixes#7253
Co-authored-by: Ahmed Allam <60698204+AllamF5J@users.noreply.github.com>
* docs: Add comprehensive documentation to BinarySearch algorithm
- Added detailed JavaDoc with @param, @return, @throws tags
- Included step-by-step algorithm walkthrough example
- Added inline comments explaining each code section
- Documented time and space complexity analysis
- Provided concrete usage examples with expected outputs
- Explained edge cases and overflow prevention technique
* style: Apply proper Java formatting to BinarySearch
- Fixed line length to meet style guidelines
- Applied proper JavaDoc formatting
- Corrected indentation and spacing
- Ensured compliance with project formatting standards
* fix: correct Javadoc formatting and add missing newline at EOF
- Fix Javadoc structure with proper tag ordering (description before @params)
- Remove incorrect @throws tag (method returns -1, doesn't throw)
- Format algorithm steps as proper HTML ordered list
- Move complexity analysis before @param tags
- Add missing newline at end of file
- Fix example code to use instance method call
* feat: implement Smooth Sort algorithm with detailed JavaDoc and test class
* style: format LEONARDO array for improved readability with clang-format
* feat: add MiddleOfLinkedList class and corresponding test cases
* docs: update documentation for MiddleOfLinkedList class
* test: refactor MiddleOfLinkedListTest to improve readability and assertions
* test: refactor MiddleOfLinkedListTest for improved null safety and readability
---------
Co-authored-by: Ahmed Allam <60698204+AllamF5J@users.noreply.github.com>
* feat: implement Smooth Sort algorithm with detailed JavaDoc and test class
* style: format LEONARDO array for improved readability with clang-format
* feat(sorts): add TournamentSort (winner-tree)
* test: add unit test for null array handling in TournamentSort
* feat(search): add rotated binary search
* test: add unit test for handling middle element in right sorted half of rotated array
---------
Co-authored-by: Ahmed Allam <60698204+AllamF5J@users.noreply.github.com>
* feat: implement Smooth Sort algorithm with detailed JavaDoc and test class
* style: format LEONARDO array for improved readability with clang-format
* feat(sorts): add TournamentSort (winner-tree)
* test: add unit test for null array handling in TournamentSort
---------
Co-authored-by: Ahmed Allam <60698204+AllamF5J@users.noreply.github.com>
Co-authored-by: Deniz Altunkapan <deniz.altunkapan@outlook.com>
Co-authored-by: Oleksandr Klymenko <19151554+alxkm@users.noreply.github.com>
* feat: implement Smooth Sort algorithm with detailed JavaDoc and test class
* style: format LEONARDO array for improved readability with clang-format
---------
Co-authored-by: Ahmed Allam <60698204+AllamF5J@users.noreply.github.com>
* Add StochasticMatrix utility class
This class provides methods to check if a matrix is row-stochastic or column-stochastic, ensuring all elements are non-negative and the sums of rows or columns equal 1.
* Change package from maths to matrix
Updated package declaration for StochasticMatrix class.
* Change package declaration in StochasticMatrixTest
* Delete src/test/java/com/thealgorithms/StochasticMatrixTest.java
* Refactor matrix initialization for test cases
* Fix formatting of matrix initialization in tests
* Remove unnecessary newline in StochasticMatrix
* Add import statement for JUnit in StochasticMatrixTest
* Add additional assertions to StochasticMatrixTest
* Clean up import statements in StochasticMatrixTest
Removed unused import statements for cleaner code.
* Reorder import statements in StochasticMatrixTest
* Remove unused import assertThrows from StochasticMatrixTest
Removed unused import for assertThrows.