Commit a3083ec
authored
feat: add Naive Pattern Search algorithm
This commit adds the Naive Pattern Search algorithm implementation in Java.
The algorithm scans the text from left to right and checks each substring of
length m (pattern length) to find matches.
- New class: NaivePatternSearch.java
- Provides `search(String text, String pattern)` method returning all match indices
- Includes a sample main() for demonstration
Time Complexity: O(n * m)
Space Complexity: O(1)1 parent e78d53d commit a3083ec
File tree
1 file changed
+33
-0
lines changed- src/main/java/com/thealgorithms/strings
1 file changed
+33
-0
lines changedLines changed: 33 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 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 | + | |
0 commit comments