Commit a935710
Add TortoiseHareAlgo implementation with append, toString, and getMiddle methods (#6722)
* Create TortoiseHareAlgorithm.java
Implement TortoiseHareAlgo with append, getMiddle, and toString methods
- Added generic singly linked list with inner Node class
- Implemented append() to add elements
- Implemented getMiddle() using Tortoise-Hare approach
- Added toString() for readable list representation
* Create TortoiseHareAlgoTest.java
Add JUnit tests for TortoiseHareAlgo
- Verified append() and toString() output
- Tested getMiddle() for odd, even, and empty lists
- Ensured correct behavior and null handling
* Update README.md
Add TortoiseHareAlgo to linked list documentation
- Added TortoiseHareAlgo.java to file descriptions
- Described its purpose: finding middle element using Tortoise-Hare algorithm
* Rename TortoiseHareAlgorithm.java to TortoiseHareAlgo.java
Fixed build error
* Update TortoiseHareAlgoTest.java
Fixed line formatting build error
* Update TortoiseHareAlgoTest.java
Fixed line formatting build error
* Update TortoiseHareAlgo.java
Added {} after if statement instead of directly writing statement
* Update TortoiseHareAlgo.java
Fixed line formatting build error
* Update TortoiseHareAlgo.java
Added {} after if statement instead of directly writing statement
* Update TortoiseHareAlgoTest.java
Replace .* import with specific imports
---------
Co-authored-by: Deniz Altunkapan <[email protected]>1 parent 87ad52c commit a935710
File tree
3 files changed
+110
-0
lines changed- src
- main/java/com/thealgorithms/datastructures/lists
- test/java/com/thealgorithms/datastructures/lists
3 files changed
+110
-0
lines changedLines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
Lines changed: 63 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 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
Lines changed: 46 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 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
0 commit comments