Commit fe87867
committed
feat: Enhance algorithms with fixes, new implementations and comprehensive tests
## Algorithm Fixes
- **PancakeSort**: Fixed incorrect sorting logic and algorithm flow
- Corrected the main loop to work from largest to smallest elements
- Fixed findMaxIndex to search within correct bounds
- Added comprehensive documentation and complexity analysis
## New Algorithm Implementations
- **StringRadixSort**: Complete MSD Radix Sort for strings
- Efficient O(d*(n+k)) time complexity implementation
- Handles variable-length strings and Unicode characters
- Includes both copy and in-place sorting methods
- Comprehensive error handling and edge case support
- **ExtendedEuclideanAlgorithm**: Full-featured extended GCD implementation
- Both recursive and iterative implementations
- Modular multiplicative inverse calculation
- Linear Diophantine equation solver
- Comprehensive documentation with mathematical background
## Enhanced Data Structures
- **FenwickTree**: Major enhancement with comprehensive API
- Added range queries, get/set operations, and input validation
- Enhanced documentation with complexity analysis
- Better error handling and edge case support
- Added constructor for building from existing arrays
## New Comprehensive Test Suites
- **StringRadixSortTest**: 15+ test methods covering all edge cases
- **ExtendedEuclideanAlgorithmTest**: 20+ test methods with mathematical verification
- **FenwickTreeTest**: 15+ test methods with boundary and performance testing
## Code Quality Improvements
- Enhanced JavaDoc documentation with examples and complexity analysis
- Added proper error handling and input validation
- Improved code comments and algorithm explanations
- Added mathematical verification in tests
All implementations follow project coding standards and include:
- Comprehensive unit tests with edge cases
- Detailed documentation and examples
- Performance complexity analysis
- Error handling and input validation1 parent 5e9d9f7 commit fe87867
File tree
7 files changed
+1401
-10
lines changed- src
- main/java/com/thealgorithms
- datastructures/trees
- maths
- sorts
- test/java/com/thealgorithms
- datastructures/trees
- maths
- sorts
7 files changed
+1401
-10
lines changedLines changed: 162 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
3 | 35 | | |
4 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
5 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
6 | 45 | | |
7 | 46 | | |
8 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
9 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
10 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
11 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
12 | 80 | | |
13 | 81 | | |
14 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
15 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
16 | 94 | | |
17 | 95 | | |
18 | 96 | | |
19 | 97 | | |
20 | | - | |
| 98 | + | |
21 | 99 | | |
22 | 100 | | |
23 | 101 | | |
24 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
25 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
26 | 115 | | |
27 | 116 | | |
28 | 117 | | |
29 | 118 | | |
30 | 119 | | |
31 | | - | |
| 120 | + | |
32 | 121 | | |
33 | 122 | | |
34 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
35 | 192 | | |
0 commit comments